iOS布局:自动布局、栈视图与国际化处理
1. 手动布局约束示例
在布局视图时,我们可以手动设置约束来精确控制视图的位置和大小。以下是一段手动设置约束的代码示例:
guides[1].widthAnchor.constraint(equalToConstant:10),
guides[2].widthAnchor.constraint(equalToConstant:10),
// bottom of each view is top of following guide
views[0].bottomAnchor.constraint(equalTo:guides[0].topAnchor),
views[1].bottomAnchor.constraint(equalTo:guides[1].topAnchor),
views[2].bottomAnchor.constraint(equalTo:guides[2].topAnchor),
// top of each view is bottom of preceding guide
views[1].topAnchor.constraint(equalTo:guides[0].bottomAnchor),
views[2].topAnchor.constraint(equalTo:guides[1].bottomAnchor),
views[3].topAnchor.constraint(equalTo:guides[2].bottomAnchor),
// guide heights are equal!
guides[1].heightAnchor.constraint(eq
超级会员免费看
订阅专栏 解锁全文

被折叠的 条评论
为什么被折叠?



