IPhone : UIButton Height Increase Size Using AutoLayout with Different Devices

on Wednesday, March 25, 2015

I have a fully functional app and I'm creating a new View Controller in Interface Builder with buttons and labels. I've laid out everything in the Interface Builder and used AutoLayout to make sure every component is in place. It's working very well on the iPhone 5s, but with the iPhone 6 and 6 Plus, my UIButtons are not resizing it's height to adjust to the bigger screens.


A screenshot would make help make more sense of this.


iPhone 5s enter image description here


iPhone 6 Plus enter image description here


The Update Me text is one UILabel. The Basic to the bottom PRO Unlimited is one UILabel. The buttons are separate UIButtons. The Restore Purchases is a UIButton and the final text on the bottom is a UILabel.


The constraints I have in place which matter are:


Basic Label


Trailing Space to Superview


Leading Space to Superview


Bottom Space to Restore Purchases UIButton


Top Space to UpdateMe UILabel


Buy 100 UIButton


Leading Space to Superview


Trailing Space to Buy Unlimited UIButton


Top Space to Top Layout


Bottom Space to Restore Purchases UIButton


Equal Width to Buy Unlimited UIButton


Buy Unlimited UIButton


Trailing Space to Superview


Leading Space to Buy 100


Top Space to Top Layout


Bottom Space to Restore Purchases UIButton


Equal Width to Buy 100


Restore Purchases UIButton


Trailing Space to Superview


Leading Space to Superview


Top Space Basic UILabel


Bottom Space to A One Off UILabel


Top Space to Buy Unlimited


Top Space to Buy 100


On the iPhone 5s, the Restore Purchases UIButton has a width of 268 and height of 30.


On the iPhone 6 Plus, the Restore Purchases UIButton has a width of 382 and height of 198, so clearly that's taking up a huge chunk of space which causes the UIButton to not increase.


What I would like to achieve is, every component in it's place as it is now, but on the iPhone 6 Plus, have the Buy 100 and Buy Unlimited UIButtons to increase in height with the width to stay the same.


Any guidance on this would really be appreciated!


0 comments:

Post a Comment