如何改变UIView的中心,在故事板中添加?

时间:2016-07-26 05:03:08

标签: ios swift uiview

我通过Storyboard添加了UIButton和UIView,并创建了他们的IBOutlets

@IBOutlet weak var popUpView: UIView!
@IBOutlet weak var nextButton: UIButton!

当我尝试更改centerframe时,它不起作用:

override func viewDidAppear(animated: Bool) {
        super.viewDidAppear(animated)
        popUpView.center = CGPoint(x:50,y:50)
        nexButton.frame = CGRect(x: 0, y: 50, width: 100, height: 100)
    }

但这有效:

nextButton.layer.cornerRadius = 0.2 * nextButton.bounds.size.width

1 个答案:

答案 0 :(得分:0)

我添加了底部约束的出口,并进行了更改。谢谢@Bharat Modi