Set the center of a UIButton programmatically - SWIFT

后端 未结 5 1495
孤街浪徒
孤街浪徒 2021-02-19 11:22

I have a UIButton inside a UIView, my UIButton has constraints which I set in storyboard. Now, I want to set the center of the UIBut

5条回答
  •  甜味超标
    2021-02-19 11:34

    I should be

    yourButton.setCenter(self.view.center);
    

    But keep in mind that if you programmatically set the frame of a view, your layout constraints might not work as intended.

提交回复
热议问题