swift - 具有自动布局的 SnapKit 快速
问题描述
我根据 iPhone X 版本编辑了我的应用程序。其他 iPhone 型号由于此图像的屏幕尺寸已损坏。如何编辑根据 iPhone 版本定义的值?例如,我分享一个示例代码:
registerlabel.topAnchor.constraint(equalTo: view.topAnchor, constant: 735).isActive = true
registerlabel.widthAnchor.constraint(equalTo: view.widthAnchor, constant: 0).isActive = true
registerlabel.centerXAnchor.constraint(equalTo: view.centerXAnchor, constant: 157).isActive = true
registerlabel.heightAnchor.constraint(equalToConstant: 40).isActive = true
registerlabel.snp.makeConstraints { (make) in
make.top.equalTo(self.chipField).offset(370)
make.right.equalTo(140)
}
虽然 registerlabel 出现在 iPhone X 上,但这个标签复选框不会出现在 iPhone 6 上。
我根据参考设置了chipfield的位置,但没有。
解决方案
而不是从你那里设置你的registerLabel
位置chipfield
应该使用 parentView 底部。这样您就可以在任何屏幕上使用它。
make.bottom.equalToSuperView().offset(20) //Offset from bottom
推荐阅读
- java - websphere部署生成的web_merged.xml和ibm-metadata.xml文件是什么?
- c# - C# Mongodb 通过查找进行搜索很昂贵
- typescript - 道具可能未定义
- angular - 在ionic5中使用大量项目时离子切片的性能问题
- python - 如何使用(x,y)python将行拟合到2个数组
- r - 指定外部库但不在函数级别
- python - Pandas 合并具有相同 id 行的列表
- angular - 以角度的静态方法访问 ag-Grid ColumnApi
- mysql - 在 Mysql for Postgresql 中替代“set @myvariable = value”
- intellij-idea - 如何在 IntelliJ IDEA 的拆分选项卡中打开新文件?