Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

straber

macrumors member
Original poster
Jul 3, 2012
60
0
Hi,

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?

Thanks,
 

Attachments

  • blueButton.png
    blueButton.png
    1.4 KB · Views: 206
  • photo 2.jpeg
    photo 2.jpeg
    39 KB · Views: 2,771
  • photo 1.jpeg
    photo 1.jpeg
    40.9 KB · Views: 111
Last edited:
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.

Code:
    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.
 
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.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.