码迷,mamicode.com
首页 > 其他好文 > 详细

NSLayoutConstraint 设置优先级

时间:2020-02-19 10:28:56      阅读:184      评论:0      收藏:0      [点我收藏+]

标签:top   cardview   int   utc   ios   guid   隐藏   pre   bsp   

 

//显示提交按钮 时的约束
    private var svBottomCon:NSLayoutConstraint?
    
    //隐藏提交按钮 时的约束
    private var svUpdateBottomCon:NSLayoutConstraint?


    //显示有数据的UI , 不能编辑,隐藏提交按钮  此时设至 高约束等级 defaultHigh
  func showDataUI(){ bindCardView.updateTempUI() self.submitBtn.isHidden = true if #available(iOS 11.0, *) { svUpdateBottomCon = scrollView.bottomAnchor.constraint(equalTo: view.safeAreaLayoutGuide.bottomAnchor, constant: -20) } else { svUpdateBottomCon = scrollView.bottomAnchor.constraint(equalTo: view.bottomAnchor, constant: -20) } svUpdateBottomCon?.priority = UILayoutPriority.defaultHigh svUpdateBottomCon?.isActive = true } 
//默认UI 设置 第一次的约束等级是
defaultLow
if #available(iOS 11.0, *) { scrollView.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor, constant: 20).isActive = true svBottomCon = scrollView.bottomAnchor.constraint(equalTo: view.safeAreaLayoutGuide.bottomAnchor, constant: -102) submitBtn.bottomAnchor.constraint(equalTo: view.safeAreaLayoutGuide.bottomAnchor, constant: -30).isActive = true } else { scrollView.topAnchor.constraint(equalTo: view.topAnchor, constant: 20).isActive = true svBottomCon = scrollView.bottomAnchor.constraint(equalTo: view.bottomAnchor, constant: -102) submitBtn.bottomAnchor.constraint(equalTo: view.bottomAnchor, constant: -30).isActive = true } svBottomCon?.priority = UILayoutPriority.defaultLow svBottomCon?.isActive = true

 

NSLayoutConstraint 设置优先级

标签:top   cardview   int   utc   ios   guid   隐藏   pre   bsp   

原文地址:https://www.cnblogs.com/qingzZ/p/12329985.html

(1)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!