UIImageView height on iPhone 6 and iPhone 6 Plus Z

2019-09-01 02:47发布

问题:

I have a UIImageView *backgroundImageView in my ViewController and call in my viewDidLoad

[self.backgroundImageView sizeToFit]

I found that on the iPhone 6 the height changes from 667 (Normal display) to 558 (Zoomed display)

However on the iPhone 6 Plus the height remains the same at 736 for both.

Is this expected?

回答1:

Try it. Here Given code based on your current screen height.

float img = frame.size.height / frame.size.width;

frame.size.width = [[UIScreen mainScreen] bounds].size.width;

frame.size.height = frame.size.width * img ;