Resolved button suddenly does not look like its image

Discussion in 'iOS Programming' started by straber, Apr 5, 2013.

  1. straber, Apr 5, 2013
    Last edited: Apr 6, 2013

    straber macrumors member

    Jul 3, 2012

    I have a UIButton I've been using for awhile using an image to give it its look. The image has not changed, nor has any of the code for the button, but it suddenly looks much darker than it used to and I have no idea why this would be. I've attached photos. The login button should be the light blue color but looks dark purple in one version. Any ideas why this would be?


    Attached Files:

  2. xStep macrumors 68000

    Jan 28, 2003
    Less lost in L.A.
    Your blue button has transparency in the colors. Transparent blue displayed over that orange is going to get you the purple. The only way to counter that is to either not have transparency in the non-corner area, or place a white background behind the graphic.

    A fix is to set the buttons layer to white or off white and set the corner radius to match your graphics corner radius. The following is what I experimented with and got good results. I used your graphic.

        CGColorRef newButtonBackgroundColor = [[UIColor colorWithRed: 0.9 green: 0.9 blue: 0.9 alpha: 1.0] CGColor];
        myButton.layer.backgroundColor = newButtonBackgroundColor;
        myButton.layer.cornerRadius = 12.0;
    An oddity I notice is that your light blue button has a very dark line at the bottom of it, while mine does not. The line is not in the graphic. It looks to me like you were already setting up a layer and used the shadow attributes for this.
  3. straber thread starter macrumors member

    Jul 3, 2012
    Thanks, that worked perfectly, although it makes me curious as to why the button looks the right shade of blue on one orange background, but looks purple on the other orange background. Either way thanks for the help.

Share This Page