https://github.com/ljunb/zelda
支持链式语法的轻量FlexBox布局库
https://github.com/ljunb/zelda
Last synced: about 2 months ago
JSON representation
支持链式语法的轻量FlexBox布局库
- Host: GitHub
- URL: https://github.com/ljunb/zelda
- Owner: ljunb
- License: mit
- Created: 2021-08-14T05:32:30.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2021-08-17T13:53:49.000Z (almost 4 years ago)
- Last Synced: 2025-03-28T23:44:02.652Z (2 months ago)
- Language: Objective-C
- Homepage:
- Size: 27.3 KB
- Stars: 4
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Zelda
[](https://travis-ci.org/ljunb/Zelda)
[](https://cocoapods.org/pods/Zelda)
[](https://cocoapods.org/pods/Zelda)
[](https://cocoapods.org/pods/Zelda)`Zelda` 是一个支持链式语法的 FlexBox 布局库,是针对 [YogaKit](https://github.com/facebook/yoga/tree/main/YogaKit) 的二次封装,可以快速的让 iOS 原生开发人员使用 FlexBox 技术进行
UI 布局。## 安装
```ruby
pod 'Zelda'
```## 简单使用
```objc
#importUIView *container = [UIView new];
container.backgroundColor = UIColor.redColor;
[self.view addSubview:container];
container
.zelda
.flexDirection(ZDFlexDirectionRow)
.alignItems(ZDAlignCenter)
.margin(100)
.height(100)
.width(100);UIView *view1 = [UIView new];
view1.backgroundColor = UIColor.grayColor;
[container addSubview:view1];
view1.zelda.height(30).width(30);UIView *view2 = [UIView new];
view2.backgroundColor = UIColor.blueColor;
[container addSubview:view2];
view2.zelda.height(30).width(30).marginHorizontal(10);[container.zelda applyLayout];
```以 `per_` 开头使用百分比数值:
```objc
UIView *view = [UIView new];
// 代表宽高分别占据父组件的30%、10%
view.zelda.per_width(30).per_height(10);
```以 `zd_` 开头获取当前组件的布局数值:
```objc
UIView *view = [UIView new];
view.zelda.width(30).height(30);
CGFloat height = view.zelda.zd_height;
// todo something...```
## 运行示例
```shell
git clone [email protected]:ljunb/Zelda.git
cd Zelda/Example && pod install
```