Art*_*rti 7 constraints ios swift
我有这种约束的观点.我想动画它并移动到底部NavigationBar.所以我想将Second item属性更改为以下内容:
UIView.animateWithDuration(15.5, delay: 0.0, options: UIViewAnimationOptions.CurveEaseInOut, animations: {
if (self.isViewLoaded() && self.view.window != nil) {
//How to set bottom item ?
self.storeSelectViewVerticalContainerConstraint.secondItem = self.navigationController?.view.bottom
self.view.layoutIfNeeded()
}
}, completion: {(Bool) in})
Run Code Online (Sandbox Code Playgroud)
此代码返回错误:
无法分配给属性:'secondItem'是一个只用于get的属性
或者,如果此方法不可行,则如何计算,并使用导航栏将对象从中间移动到顶部.
fdi*_*iaz 17
您可以添加具有较低优先级的第二个约束来启动,然后在需要时更新两个优先级:
UIView.animateWithDuration(15.5, delay: 0.0, options: UIViewAnimationOptions.CurveEaseInOut, animations: {
if (self.isViewLoaded() && self.view.window != nil) {
self.storeSelectViewVerticalContainerConstraint.priority = UILayoutPriorityDefaultLow
self.storeSelectViewTopContainerConstraint.priority = UILayoutPriorityDefaultHigh
self.view.layoutIfNeeded()
}
}, completion: {(Bool) in})
Run Code Online (Sandbox Code Playgroud)
请记住,不要将优先级从必需移动到不需要,因为这是不允许的.但是从可选值移动到另一个可选值是可以的.
或者,您可以删除/添加这些约束,而不是更改其优先级.
| 归档时间: |
|
| 查看次数: |
5686 次 |
| 最近记录: |