changing constraints at runtime in swift

后端 未结 2 1756
一个人的身影
一个人的身影 2021-01-25 06:53

I\'m really very weak in constraints part of ios. I have gone through many reference link as shown below but still not able solve my issue.

Hide autolayout UIView : How

2条回答
  •  悲&欢浪女
    2021-01-25 07:11

    I use outlets for constraints set on the storyboard, for divs between buttons (using old ways to set dynamic layouts). So, for large screens (iPhone 6 and above), I update the values of fixed heights (app only viewed in portrait mode). What worked for me is:

    constHeightlogo.constant = 140 //old value = 72
    ///set any other updates here then force the view
    self.view.layoutIfNeeded()
    

    Worked like a charm.

    See related here:

    Update the constant property of a constraint programmatically in Swift?

提交回复
热议问题