Adri
Adri

Reputation: 243

How can I prevent Xcode from changing the color of my buttons?

So I've done a button for my iPad app, and I saw something strange. When I run my app in the iOS 5 simulator, it changes the color, and the lines of my button become discontinuous. But when I push it, the button comes back to the right color, and the lines are ok. I think it's something that Xcode does automatically with any button, and I don't find the way to cancel it. Thank you for helping!

PS: The button code is so simple:

IBOutlet UIButton *button;

This is what it should look like:

enter image description here

And this is how it looks in the simulator:

enter image description here

Upvotes: 1

Views: 391

Answers (3)

eric.mitchell
eric.mitchell

Reputation: 8845

Both tams and JacobFennell have good points, but you should also note that graphics are often represented much differently on the simulator than on a real device. You should try running your app on a device and see if the problem persists; I have had many 'problems' with custom buttons which turned out just to be improper rendering on the part of the simulator.

Upvotes: 1

JacobFennell
JacobFennell

Reputation: 468

Your button frame size doesn't seem to match the size of your image. Your art should match the (button/view) frame size pixel for pixel, otherwise you may get blurry images and scaling representation artifacts.

Else, you can change the view content mode (UIViewContentMode) of the frame from UIViewContentModeScaleToFill to UIViewContentModeTopLeft

Upvotes: 1

tams
tams

Reputation: 830

Since you are using the Interface builder, make sure that you are setting the button type to custom and that you have changed the behavior for all of the states. Under the dropdown menu of where you can set the type they also have StateConfig, where you can configure the look and text of your button for all of its different states: highlighted, default, disabled...Check that those settings are correct as well.

Hope this helps! Tams

Upvotes: 1

Related Questions