# NerdyUI
[![Platform](http://cocoapod-badges.herokuapp.com/p/NerdyUI/badge.png)](https://cocoapods.org/pods/NerdyUI)
[![Language](https://camo.githubusercontent.com/329dad681452751ddf3fed2c8a32d2c4515ae03b/687474703a2f2f696d672e736869656c64732e696f2f62616467652f6c616e67756167652d4f626a432d627269676874677265656e2e7376673f7374796c653d666c6174)](https://cocoapods.org/pods/NerdyUI)
[![Version](http://cocoapod-badges.herokuapp.com/v/NerdyUI/badge.png)](https://cocoapods.org/pods/NerdyUI)
[![License](http://cocoapod-badges.herokuapp.com/l/NerdyUI/badge.png)](https://cocoapods.org/pods/NerdyUI)
An easy way to create and layout UI components for iOS 8 and above.
There is also a [Swift version](https://github.com/nerdycat/Cupcake) available.
相关文章:
[中文说明](http://www.jianshu.com/p/ac47c4826a19)
[NerdyUI 使用小技巧](http://www.jianshu.com/p/c9ac29fb634e)
---
## Macros for create NSString, UIFont, UIColor, UIImage and Common structs
You can convert nearly everything to NSString by using `Str()` macro.
Similarly, you can log variables using `Log()` macro.
Str(100); //@"100"
Str(3.14); //@"3.14"
Str(@0.618); //@"0.618"
Str(view.frame); //@"{{0, 0}, {100, 100}}"
Str(view.center); //@"{50, 50}"
Str(_cmd); //@"viewDidLoad"
Str(NSString.class); //@"NSString"
Str("C-String"); //@"C-String"
Str(@"1 + 1 = %d", 1 + 1); //@"1 + 1 = 2"
Log(100);
Log(3.14);
Log(@0.618);
Log(view.frame);
...
Log(@"1 + 1 = %d", 1 + 1);
//Appending String
@"1".a(@"2").a(3).a(nil).a(4.0f).a(@5).a(@"%d", 6); //@"123456"
You can create NSAttributedString with `AttStr()` macro.
AttStr(@"hello, 101").match(@"[0-9]+").underline; //mark 101 with underline
AttStr(@"A smile ", Img(@"smile"), @" !!"); //attributedString with image attachment
You can create UIFont with `Fnt()` macro.
Fnt(15); //[UIFont systemFontOfSize:15]
Fnt(@15); //[UIFont boldSystemFontOfSize:15]
Fnt(@"body"); //UIFontTextStyleBody
Fnt(@"Helvetica,15"); //helvetica font with size 15
You can create UIColor with `Color()` macro.
Color(@"red"); //[UIColor redColor]
Color(@"0,0,255"); //RGB color
Color(@"#0000FF"); //Hex color
Color(@"random"); //random color
//also can have an optional alpha value
Color(@"red,0.5"); //red color with alpha 0.5
Color(@"0,0,255,0.8"); //blue color with alpha 0.8
...
Color(Img(@"pattern")); //pattern image color
You can create UIImage with `Img()` macro.
Img(@"imageName"); //[UIImage imageNamed:]
Img(@"#imageName"); //prefixed with # will return an stretchable image
Img(@"red"); //1x1 square image with red color
You can also create CGPoint, CGSize, CGRect, NSRange and UIEdgeInsets with `XY()`, `WH()`, `XYWH()`, `Range()`, `Insets()` macros.
CGPoint p = XY(20, 20);
CGSize s = WH(50, 50);
CGRect f1 = XYWH(20, 20, 50, 50);
CGRect f2 = XYWH(f1.origin, f1.size);
CGRect f3 = XYWH(f2.origin, 50, 50);
CGRect f4 = XYWH(20, 20, f3.size);
NSRange r = Range(10, 20);
UIEdgeInsets i1 = Insets(10); //{10, 10, 10, 10}
UIEdgeInsets i2 = Insets(10, 20); //{10, 20, 10, 20}
UIEdgeInsets i3 = Insets(10, 20, 30); //{10, 20, 30, 20}
UIEdgeInsets i4 = Insets(10, 20, 30, 40); //{10, 20, 30, 40}
These macros exist not only because they simplify the process of creating common types, but also indicate a new way of setting properties as you will see soon.
## Quick access to frame property and Screen size
someView.x = 10;
someView.y = someView.x;
someView.xy = XY(10, 10);
someView.w = 50; //width
someView.h = someView.w; //height
someView.wh = WH(50, 50);
someView.frame = XYWH(10, 10, 50, 50);
someView.cx = 25;
someView.cy = someView.cx;
someView.center = XY(25, 25);
someView.maxX = 60;
someView.maxY = someView.maxX;
someView.maxXY = XY(60, 60);
//qucik access screen size
someView.wh = WH(Screen.width, Screen.height);
## Easy way to set up UI components
NerdyUI make it very easy to create UI components and config properties by using a chaining syntax.
UIView *view1 = View.xywh(20, 30, 50, 50).bgColor(@"red").opacity(0.7).border(3, @"3d3d3d");
UIView *view2 = View.xy(80, 30).wh(view1.wh).bgColor(@"blue,0.7").borderRadius(25).shadow(0.8).onClick(^{
Log(@"view2");
});
<img src="./res/view.png" alt="view" width="30%" />
UIImageView *moose = ImageView.img(@"moose").x(20).y(100).shadow(0.6, 2, -3, -1);
UILabel *quiz = Label.str(@"%d+%d=?", 1, 1).fnt(@17).color(@"66,66,66").fitSize.x(moose.maxX + 10).cy(moose.cy);
<img src="./res/moose.png" alt="moose" width="30%" />
id title = AttStr(@"TAP ME").fnt(15).underline.range(0, 3).fnt(@18).color(@"random");
UIButton *button1 = Button.str(title).insets(5, 10).fitSize.border(1).xy(20, 150).onClick(^(UIButton *btn) {
//Exp allows you to execute codes in any position.
quiz.text = Str(@"%d+%d=%d", 1, 1, Exp(btn.tag += 1));
[quiz sizeToFit];
});
UIButton *button2 = Button.str(@"HAT").highColor(@"brown").img(@"hat").gap(8);
button2.xywh(button1.frame).x(button1.maxX + 10).borderRadius(5).bgImg(@"blue,0.5").highBgImg(@"orange");
//highBgImg with color string is a very useful trick to set highlighted background color for UIButton.
<img src="./res/button.gif" alt="button" width="50%" />
id pinField = TextField.x(button1.x).y(button1.maxY + 15).wh(170, 30).onChange(^(NSString *text) {
//self has been weakified, no need to warry about retain cycle.
[(id)[self.view viewWithTag:101] setText:text];
}).numberKeyboard.maxLength(4).hint(@"pin code").fnt(15).roundStyle;
id textView = TextView.xywh(20, 240, 170, 100).border(1).insets(8).hint(@"placeholder").fnt([pinField font]).tg(101);
<img src="./res/input.gif" alt="input" width="50%" />
As you can see, most of the chainable properties are quite straight forward and self-explained. Some of them are very versatile and can take many kind of arguments. By the way, `View` is just a Macro for `[UIView new]`, same as others.
You use `.opacity()` and `.tg()` to set view's alpha and tag.
You use `.x()`, `.y()`, `.xy()`, `.w()`, `.h()`, `.wh()`, `.xywh()`, `.cx()`, `.cy()`, `.cxy()`, `.maxX()`, `.maxY()`, `.maxXY()` to set view's position and size.
You use `.touchEnabled`, `.touchDisabled` to enable or disable touch.
You use `.flexibleLeft`, `.flexibleRight`, `.flexibleTop`, `.flexibleBottom`, `.flexibleLR`, `.flexibleTB`, `.flexibleLRTB`, `.flexibleWidth`, `.flexibleHeight`, `.flexibleWH` to set autoresizingMask.
You use `.centerAlignment`, `.rightAlignment` to set alignment.
You use `.fnt()` to set font with the same format as `Fnt()`.
You use `.str()` to set text or attribtedText with the same format as `Str()`.
You use `.img()`, `.highImg()`, `.bgImg()` and `.highBgImg()` to set image, highlightedImage, backgroundImage and highlightedBackgroundImage, with the same format as `Img()`.
You use `.tint()`, `.color()`, `.bgColor()`, `.highColor()` to set tintColor, textColor, backgroundColor and highlightedTextColor, with the same format as `Color()`.
You use `.border()`, `.borderRadius()` and `.shadow()` to config border styles and drop shadows.
You use `.fitWidth`, `.fitHeight` and `.fitSize` to change bounds to fit content.
You use `.onClick()` to add click handler to any UIView.
For UITextField and UITextView, you use `.hint()` to set placeholder, `.maxLength()` to limit the total length, `.onChange()` for adding text change handler.
For UIButton, UITextField and UITextView, you use `.insets()` to add padding to contents.
An there are many more. Check the corresponding header file for more information.
##Enhancements to UILabel
You can add line spacing to UILabel by simply use `.lineGap()`.
You can add link to UILabel as well. All you have to do is create an NSAttributedString that marked as `.linkForLabel`, and then add a link click handler to UILabel with `.onLink()`.
id str = @"Lorem ipsum 20 dolor sit
没有合适的资源?快使用搜索试试~ 我知道了~
(OC)TabbarViewController
共279个文件
m:50个
h:50个
png:17个
需积分: 2 1 下载量 174 浏览量
2022-10-18
16:44:18
上传
评论
收藏 523KB ZIP 举报
温馨提示
(OC)TabbarViewController
资源详情
资源评论
资源推荐
收起资源包目录
(OC)TabbarViewController (279个子文件)
01e825b514849fef77a8d87b32ea731d9a418d 243B
03d1fb73497a0ea9aca10e58adacb893a1e220 826B
0723e14542296e6b99b68d190aa35c704470df 8KB
08767942efb50b50b9a3c79288121cd70a2a9f 58B
0cd074629963784d23bffaaa5776a6763ebe0f 1KB
0ed2789676b2741555abd4092c1110317ab4c3 159B
12b95e486df4f9d0745c5c771f295faa0b5e4d 159B
14a58d9ec8bb7abc7bcdcd654f2ced6c48f43b 596B
1c7bf800d611ba1612aef60f452797ef0e83ba 476B
20035583f1e041414406df44fc99b39ec3dcbf 194B
201c4917f2987d96ab3ec913acec0a4161b2f8 236B
21357f3270e789bd8f8340dc7d3cfb636fa242 157B
216a1fd694632826098df1a78e80e4a1fd904e 1KB
21f06e905568116978e771cb26f993b94ba180 963B
26b3012bc068f6edc9e4ab2cab10ee16a0edeb 280B
27d13ce1d072e9c50f16b0ad5fe05178a327f6 194B
289bc4397e11b6726f888f77788a87652d342a 2KB
2998ac8dc834c96bd04233cb3b9a0fe4aa5a5f 2KB
3348d87704fa6b151e425325bd52055b823c47 101B
36568c7037e8ccbe3c6fc7e9d531dfe75e5c64 557B
3815f0a1676d132c81e4b25e4db74f1e67b1ff 4KB
386774e0c8dd900bedd962b682ef46eb9d32ce 4KB
3905e918941982f39742153219b453ab5d4ca7 194B
3909d3aa204a1f45cab467336d8f077dbcf1e7 168B
3c75e91c2d0bd16da57d4b36739265d3036a83 499B
3cc9b8ba4e4ae5c6df5ed5e3f199668b7fead0 68B
3e2e71d28a09e8adae2609677b786a3b26999c 497B
3f6fd5810b9c852cf98563d82d5ed1e84ff893 804B
40a6cd0c4af2f0d93b697fbfb066793681b045 352B
4a164c918651cdd1e11dca5cc62c333f097601 65B
4b8aa5c8a43bb4146cb173272b88372490ec9a 194B
526f02f55afd650cf9e8d9758f798206c27f88 64B
52ca6921d552607cc9908edbf8b98d1be58a02 499B
55b400e562ba52e2d8823773e27d8618190bf9 329B
56de01829d9c4c4642f32fee03403670041379 162B
59e8dcc11e7f7f8860b4bd0459336246a9c917 157B
5a354fceaf78e8c17e40927cf3b57b500a03c1 4KB
5be411be8c4d95b9611fb1ab242b57ec987b52 129B
635f938c5d0a96365ac7cb296603d5bbfad8ba 668B
6550d0b1a8f00cae221e421e9f56833436348a 159B
686f439982189785f3dd168b71dd8a30389db5 932B
6d2f6d64938427221b4e3288d5de119d3d0e93 4KB
744bbf3322b9897cf13106ca6c80bc0bcdd396 170B
7bf4c3aac8d5c624057026b79d61a575c89fde 159B
7c4c94fa589d243e39d0facfb1a35b11bca556 1KB
7f1e2675ec2996d8cb34010e449a959b90ef8c 1KB
805b861fe36cb73785f9f2af1b9668597a5556 499B
8481b953fdbea60ce22487b6a5424cbf1a4ae7 158B
84b2aec2b110f8c1b3dad78f68eca37ace2e2a 142B
8625fbeea5761ffbfd95d7974ee220a6b43db9 481B
8adbdcf3ccc6dd4eec50c9b408f8e750aff897 93B
8bef15b5a28957403c2dfb6029e57f152e1ba2 749B
8f26b0736265a5cfeecb1c66b280d025c07ef5 95B
9ab5ca4c17fb258d32f1a940de6dcd7e1855d0 156B
9b0f338c973664fa818e551d0f9ba031c2c83c 499B
9e88e07654877a8530579d6c904583036dc783 2KB
9f89b85ec9191157517324a807c9f8d9a8b32e 95B
a262c009508f4513ff9c8018a41677bc6db2d8 4KB
a5059ccfb75b1892cfa0c45b44f849fdbd5495 159B
a5472ab3b6a56f18e21dc6afa30ccb85801fdd 3KB
a70be3e0ccd98be0a578d70ef0bbfa3b0ecf42 52B
ade3341219ab1e2e234830560de9fc9aeb7cf6 163B
ae55a30b2310886872f3781f09c6f64d56970c 160B
af53b0c8276dd5cb49c1b23b47a68773b55536 3KB
b5450d10e24a5c7293faddc84173e7f5b80049 740B
b66c578f152532d1410dbc298c357768a6cc39 104B
bc46ff6765e17c7a738f3ffe552df41ad3374e 194B
bd41d62b22d4c7da92e8c95d629a4d8db3bb26 992B
be3b681122de83e380d47b840b7d0486f71f86 540B
bef8ae1c838c5a8f4c129e625daddce348272d 156B
c00596a7fca3f3d4bdd64053b69d86745f9e10 66B
c78a1255c016bde922c849eef8555881c207b6 768B
c86c0539fa5c0975a6ed75fc3740daa5e2ef46 162B
cc54c6e9fe4cc65a28345ad6c6208d93f760b2 655B
cf20566f5238c77981647fee52a3f058f29aa6 743B
COMMIT_EDITMSG 15B
config 137B
d3548f2328b3677aa192f4397eb993d9812b84 8KB
d47f49e38d87a40f7cf091d7387b221df82df1 130B
d6aa390694e2ce2e730b439b81cda6566d46fd 155B
d981003d68d0546c4804ac2ff47dd97c6e7921 206B
db8d65fd79fd541b2b7eba75c7378af3448f9c 254B
ddd635c3a2a5de53b263db01e226cded6a7f4d 285B
description 73B
.DS_Store 6KB
.DS_Store 6KB
e005ddf929e68d979c872427c89c7df1e2af65 519B
e4934782fc7555554d911cd6c302365850ec63 676B
e54d21946d9511962bb731cbd5ec6c963fd635 4KB
e9b743d21219dd9ce28708f275beb6324278cb 498B
ea7390a9d3d1332e719582c86ea312f0e15110 4KB
ed60a13f7209bdb6ab996269433ace42352255 159B
eee4b66e288dd50d93c68dbdb2b7719b37e71e 336B
exclude 40B
f11cd4bdac907c8f1accf809d83e1c5746f389 194B
f343caaf701adee066c4e06ae86fa8aeb587bf 68B
f761d30c984790107e2d791b098d1d30993a1b 133B
facf1c24222badaefb8c5d7b6751eb7ef71d02 194B
ff7d3d0ddc063a595a99ba8a80e23a250c7930 3KB
fffd80e2650e9da665e451386ffd236e208e75 296B
共 279 条
- 1
- 2
- 3
冯汉栩
- 粉丝: 284
- 资源: 491
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0