极为简化的约束组件,一行代码解决约束布局问题。
需求
- Xcode 9.0+
- iOS 9.0+
- 与 Swift 4.0+ 兼容
安装
CocoaPods
首选安装方法是使用 CocoaPods。将以下内容添加到您的 Podfile
pod 'ConstraintsKit'
快速开始
Objc
#import <ConstraintsKit/ConstraintsKit.h>
view.wy_left(button).wy_right(button).wy_top(button.bottomAnchor).offset(5).wy_height(30);
//Or like this
view
.wy_left(button)
.wy_right(button)
.wy_top(button.bottomAnchor).offset(5)
.wy_height(30);
//Or like this
[view wy_makeConstraints:^(WYConstraints *make) {
make.wy_left(button);
make.wy_right(button);
make.wy_height(30);
make.wy_top(button.bottomAnchor).offset(5);
}];
//You can modify the height you just set
view.wy.heightConstant.constant = 50;
Swift
import ConstraintsKit
view.wy_left(button).wy_right(button).wy_top(button.bottomAnchor).offset(5).wy_height(30)
//Or like this
view.wy_makeConstraints { (make) in
make.wy_left(button)
make.wy_right(button)
make.wy_height(30)
make.wy_top(button.bottomAnchor).offset(5)
}
许可证
ConstraintsKit
是受MIT许可证约束的。