Centering two buttons with Cocoa Auto Layout

后端 未结 7 1621
抹茶落季
抹茶落季 2021-02-03 22:13

I have a problem with Cocoa Auto Layout and can\'t get my head around this problem. All I\'d like to achieve is to have two buttons always centered in a view as depicted below.<

相关标签:
7条回答
  • 2021-02-03 23:19

    Great tips. In my case i wanted the buttons to be centered 10 pixels apart from the center of my view so my math is slightly different

    leadingConstraint.constant = (self.frame.size.width / 2.0) + 5.0;
    trailingConstraint.constant = (self.frame.size.width / 2.0) + 5.0;
    
    0 讨论(0)
提交回复
热议问题