Nothing happens but why ???
@IBOutlet weak var button10: UIButton!
override func viewDidLoad() {
super.viewDidLoad()
button10.center = CGPoint(x: self.view.frame.x/2, y: self.view.frame.y/2)
}
On
As Ashhish said, add two constraints between the parent view and the button. But this can also be done using the awesome Github project Cartography:
layout(view, button) {
parent, button in
button.centerX == parent.centerX
button.centerY == parent.centerY
}
Very neat!
You can include Cartography using Cocoapods.
Add constraints for center in view