@H_301_8@
@H_301_8@
func buttonpressed(_ button: UIbutton) { button.bottomSpaceConstraint.constant += 10 button.horizontalAlignment.constant += 10}
先感谢您!@H_301_8@解决方法 为了扩展Stormsyder的答案,使用过滤方法可以更清晰地做同样的事情.请参阅以下内容:
@H_301_8@
@H_301_8@
let bottomConstraint = button.supervIEw!.constraints.filter({ .firstAttribute == .bottom && .firstItem == button }).first!let horizontalAllignmentConstraint = button.supervIEw!.constraints.filter({ .firstAttribute == .centerX && .firstItem == button }).first!
请注意,如果这些约束不存在,这将会崩溃,因此请确保它们安全地执行或解包.@H_301_8@ 总结
以上是内存溢出为你收集整理的ios – 以编程方式获取uibutton的约束全部内容,希望文章能够帮你解决ios – 以编程方式获取uibutton的约束所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)