coderz blog

husky

2021-04-09

名字没想好,就暂且叫它 husky

写 husky 动机

Masonry 的横空出世,其链式编程的姿势屡试不爽,相比于iOS的书写姿势更见其🐂, Masonry 中能实现这种链式编程方式那么iOS控件创建也一定能实现这种方式,在看完其内部实现后,在闲余时间决定自己将 UIKit 重写一遍达到其一样的效果,希望在开发过程中对开发效率和代码的可读性有一定的帮助。

husky 引入

支持通过 pod husky
可直接下载引入
导入头文件 #import <husky/husky.h>

用法示例

控件创建🌰
1
2
3
4
5
[UILabel generator:^(huskyer * _Nonnull huskyer) {
maker.frame(CGRectMake(100, 100, 100, 30)).text(@"哈哈").textAlignment(NSTextAlignmentCenter).textColor([UIColor whiteColor]).view(self.view).backGroudColor([UIColor redColor]).radian(CGSizeMake(25, 25)).husker(^{
NSLog(@"click");
});
}];
网络数据请求🌰
1
2
3
4
5
6
[self patch:^(Patcher * _Nonnull patcher) {
patcher.role(UIPatcherRoleGet).url(@"https://zhqd.shiminjia.com/weather.php").indicator(YES);
[patcher send:^(id _Nonnull respone) {
NSLog(@"respone---%@",respone);
}];
}];

版本设计基线

husky 中几乎涵盖了日常开发过程中用到的对象,后期还会增加一些拓展。

期待更好想法

如果您有更多好的设计和想法,可以加入我们~

Tags: iOS
使用支付宝打赏
使用微信打赏

若你觉得我的文章对你有帮助,欢迎点击上方按钮对我打赏

扫描二维码,分享此文章