Programmatically change the height and width of a UIImageView Xcode Swift Programmatically change the height and width of a UIImageView Xcode Swift ios ios

Programmatically change the height and width of a UIImageView Xcode Swift


The accepted answer in Swift 3:

let screenSize: CGRect = UIScreen.main.boundsimage.frame = CGRect(x: 0, y: 0, width: 50, height: screenSize.height * 0.2)


let screenSize: CGRect = UIScreen.mainScreen().boundsimage.frame = CGRectMake(0,0, screenSize.height * 0.2, 50)


Using autoview

image.heightAnchor.constraint(equalToConstant: CGFloat(8)).isActive = true


matomo