简体   繁体   中英

How to change center of UIView, added in storyboard?

I have added an UIButton and an UIView through Storyboard, and created their IBOutlets

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

When I try to change center or frame , it does not work:

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)
    }

But this works:

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

I added outlet of the bottom constraint, and change it. Thanks @Bharat Modi

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM