一个 UI 开发工具
Swift Package Manager
https://github.com/DingSoung/FlexUI master
UIKit 的写法
let view = UIVIew()
view.backgroundColor = .gray
view.frame = CGReact(0, 5, 200, 300)
let text = UILabel()
text.backgroundColor = .orange
text.attrbuteText = ...
text.frame = CGReact(10, 0, 200 * 0.8, 30)
view.addSubView(text)
...
func layoutSubViews() {
view.frame = ....
text.frame = ...
}
FlexUI的写法
let flexView = View()
.backgroundColor(.gray)
.top(0)
.left(5)
.width(200)
.height(300)
.children([
Text()
.backgroundColor(.orange)
.left(10)
.width(80%)
.height(30)
.flexGrow(1)
.content(Text.testAttrbuteString),
])
flexView.layout.calculateLayout()
flexView.recursiveSyncFrame()
更多用法请参考 playground