changing constraints at runtime in swift

后端 未结 2 1751
一个人的身影
一个人的身影 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?

    0 讨论(0)
  • 2021-01-25 07:22

    just make the outlet of height of both UIView and use constant property to change the height constraints like...

    if conditionfails{
         heightconstOfView1.constant = 0
    }
    else{
        heightconstOfView2.constant = 0
    }
    
    0 讨论(0)
提交回复
热议问题