如何以特定距离进行编程设置约束?
我的布局中有一个按钮,我想专门将其设置为safearea.bottom = button.bottom + 28。我尝试使用时会出现错误,
btnAddRecord.translatesAutoresizingMaskIntoConstraints = false
btnAddRecord.bottomAnchor.constraint.equalTo(self.view.safeAreaLayoutGuide.bottomAnchor, constant: 66).isActive = true
我会遇到错误的“参考'forem'qualiento'上下文类型'
我可以知道我在哪里出错以及如何解决这个问题吗?谢谢!
I have a button in my layout and I would like to specifically set it to SafeArea.bottom = button.bottom + 28. I am having errors when I try using
btnAddRecord.translatesAutoresizingMaskIntoConstraints = false
btnAddRecord.bottomAnchor.constraint.equalTo(self.view.safeAreaLayoutGuide.bottomAnchor, constant: 66).isActive = true
I am getting an error 'Reference to member 'equalTo' cannot be resolved without a contextual type'
May I know where I am going wrong and how to fix this issue? Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
语法是错误的,请尝试以下操作:
view.bottomanchor请参阅Supperiew而非SafeArea,将其相对于安全区域设置,您需要这样做:
28负会将其放在安全区域之上。
The syntax is wrong, Try This :
Also view.bottomAnchor refer to superview and not safeArea , for setting it relative to safe area , you need to do like this :
28 negative will put it above the safe area.
TranslatesAutoresizingMaskIntocontaints需要将其设置为false。
代码是:
translatesAutoresizingMaskIntoConstraints needs to be set as false.
Code Be like: