user1416564
user1416564

Reputation: 401

Image in UIButton doesn't scale when using Autolayout.

I have a UIButton that I'd like to be as wide as the view and then have the height adjust in a fixed aspect ratio. I've set my constraints for the button to be as wide as the view. And the height to be in a 2:1 aspect ratio like this (https://i.sstatic.net/pj1Bh.jpg)

But when I move it on to iPhone 6 or 6 Plus screen the image itself doesn't scale while the button does. I've added a green background color for empahsis. (https://i.sstatic.net/LrduZ.jpg)

The mode is set to Aspect Fill. And for the record I've tried multiple modes.

Any help would be appreciated.

Upvotes: 3

Views: 1142

Answers (1)

Fujia
Fujia

Reputation: 1242

Set the image as the background image for the button instead of the image property.

Upvotes: 6

Related Questions