Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Button's background on ios7 is squeezed, ios6 ok

I just updated to XCode 5. Buttons in my app look OK in IB and on iOS 6 device, but on iOS 7 device they look like this (they should cover the whole black space):

enter image description here

I have images for both non-retina/retina.

I have no idea what to do, because I didn't change anything in code or IB.

EDIT:

Now I found out, if I change type of button from custom to system and set its background instead of its image, I get the correct size but I get some strange shadow over it.

EDIT2:

Now I set button's tint color to "clear color" and everything seems ok (shadow disappeared). Still not sure what has changed in iOS 7 related to this.

like image 399
DixieFlatline Avatar asked Sep 24 '13 18:09

DixieFlatline


1 Answers

The Human Interface Guidelines specifically outline how system-style UIButtons work by default. It explains that a system button:

  • Has no border or background appearance by default ...
  • Supports custom decoration, such as a border or background image (to add a custom appearance, use a button of type UIButtonTypeCustom and supply a custom background image).

However the UIButton HIG page provides a little more information, specifically:

If you do not explicitly set a tint color, the button will inherit its superview’s tint color.

This explains why, after changing your button to UIButtonTypeSystem, you suddenly have to reset (remove) the tint colour. In iOS7, (almost) everything has a tint colour. A UIButtonTypeSystem is more appropriate for your needs now in iOS7 (a bit of a pain if there's a lot to manually change though...)

As to why the buttons shrink in iOS7... I agree with @Joseph's comment regarding UIViewController view frames in iOS7. Likely you have some set relation for the size of the buttons that does not play nicely when the ViewController's frame changes in iOS7 (see this SO question for discussion). As advised there, check out the iOS7 transition guide to see if anything you're doing in IB is going against the new iOS7-grain.

like image 57
Ephemera Avatar answered Sep 30 '22 06:09

Ephemera