I am trying to resize programmatically a UIImageView based on the device screen size, but I can´t make it work. Nothing changes.
Here´s my code:
let screenSize: CGRect = UIScreen.mainScreen().bounds
print(screenSize.height)
imgLogo.image = AppKit.appLogo
switch screenSize.height {
case 736.0:
print("iPhone 6 Plus")
imgLogo.frame = CGRectMake(0,0, 80 ,80)
case 667.0:
print("iPhone 6")
imgLogo.frame = CGRectMake(0,0, 60, 60)
case 568.0:
print("iPhone 5S")
imgLogo.frame = CGRectMake(0,0, 50, 50)
case 480.0:
print("iPhone 4S")
imgLogo.frame = CGRectMake(0,0, 40, 40)
default: break
The View Mode in Interface Builder is set to "Aspect Fit". I am also using Auto Layout with no constraints to the UIImageView width and height.
What´s the problem with this code?