4
You can do this with this code below :
let x = CGFloat(0)
let y = CGFloat(0)
let height = CGFloat(100)
let width = CGFloat(100)
viewV.frame = CGRectMake(x, y, height, width)
Your normal viewV
4
6
1
It would be interesting for you to use NSLayoutConstraint
s for this. Would be via code (more or less) like this:
// Constraints
let topConstraint = NSLayoutConstraint(item: viewV, attribute: .top, relatedBy: .equal, toItem: viewV.superview!, attribute: .top, multiplier: 1, constant: 0)
let leadConstraint = NSLayoutConstraint(item: viewV, attribute: .leading, relatedBy: .equal, toItem: viewV.superview!, attribute: .leading, multiplier: 1, constant: 0)
let widthConstraint = NSLayoutConstraint(item: viewV, attribute: .width, relatedBy: .equal, toItem: nil, attribute: .notAnAttribute, multiplier: 0.0, constant: 667)
let heightConstraint = NSLayoutConstraint(item: viewV, attribute: .height, relatedBy: .equal, toItem: nil, attribute: .notAnAttribute, multiplier: 0.0, constant: 267)
NSLayoutConstraint.activate([topConstraint, leadConstraint, widthConstraint, heightConstraint])
Browser other questions tagged ios swift mobile xcode
You are not signed in. Login or sign up in order to post.
You can use the option Aspect Ratio
– Jeferson Assis