So i have this button:
@IBOutlet var bouton: UIBarButtonItem!
And i want to change is position
But the buton doesn't seems to have a position property like for SKSpriteNode
So is there a way to change is position ?
如果要以编程方式更改任何视图的位置,可以使用以下命令:
button.frame.origin = CGPoint(x: 10, y: 10)
You can't set the button with myButton.frame.origin if you are using autolayout. So you must add constraints. For example:
let buttonConstraintY = NSLayoutConstraint(item: youButton, attribute: NSLayoutAttribute.centerY, relatedBy: NSLayoutRelation.equal, toItem: view, attribute: NSLayoutAttribute.bottom, multiplier: 1, constant: 10) self.view.addConstraint(buttonConstraintY)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.