JustLayout
认识
🏵 简介
JustLayout 是 iOS 和 tvOS 的优雅 Auto Layout 糖。
📋 要求
类型 | 要求 | |
---|---|---|
平台 |
iOS |
8.0+ |
macOS |
不适用 |
|
tvOS |
10.2 |
|
watchOS |
不适用 |
|
Linux |
不适用 |
|
IDE |
Xcode |
10.2+ |
语言 |
Swift |
5+ |
📲 安装
CocoaPods
JustLayout
可在 CocoaPods 中找到。
use_frameworks!
pod 'JustLayout'
# for DSL usage:
#pod 'JustLayout/DSL
手动安装
将 JustLayout
目录中的所有文件复制到您的项目中。
🛌 依赖项
不适用
❤️ 贡献
欢迎 fork 并提交 pull 请求。
🔖 许可证
JustLayout
是开源软件,使用 MIT
许可证。
🔫 使用方法
import JustLayout
视觉上
func visually() {
view.layout(
100,
|-topView-| ~ 80,
8,
|-centerView-(>=100)-| ~ 80,
"",
|bottomView| ~ 80,
0
)
}
连续的
func chainable() {
centerView.centerInContainer().width(100).aspectratio(followHeight: 100%)
topView.left(centerView, -20).top(centerView, -20).size(centerView)
bottomView.left(centerView, 20).top(centerView, 20).size(centerView)
}
基于操作符的
func operatorBased() {
bottomView.centerXAttribute == view.centerXAttribute
bottomView.centerYAttribute == view.centerYAttribute
bottomView.widthAttribute == 80
bottomView.heightAttribute == bottomView.widthAttribute
centerView.rightAttribute == bottomView.centerXAttribute
centerView.topAttribute == bottomView.centerYAttribute
centerView.widthAttribute == bottomView.widthAttribute
centerView.heightAttribute == bottomView.heightAttribute
topView.leftAttribute == centerView.rightAttribute
topView.topAttribute == centerView.topAttribute
topView.widthAttribute == 50 % centerView.widthAttribute
topView.heightAttribute == centerView.heightAttribute
}
自版本
1.4.0
开始,基于操作符的
布局现在支持连续使用。例如:someView.following(leftView).below(topView).size(centerView)someView.leftAttribute == leftView.rightAttribute someView.topAttribute == topView.bottomAttribute someView.widthAttribute == centerView.widthAttribute someView.heightAttribute == centerView.heightAttribute
DSL
从版本 1.5.0
开始,您现在可以使用 JustLayoutDSL
centerView.just.centerInContainer().width(100).aspectratio(100%)
topView.just.left(centerView, -20).top(centerView, -20).size(centerView)
bottomView.just.left(centerView, 20).top(centerView, 20).size(centerView)
重要
|
请先在您的 `Podfile` 中添加 |
由 Elias Abel [爱心] 制作。