码迷,mamicode.com
首页 > 移动开发 > 详细

iOS 实用Category, 批量增加子视图

时间:2015-11-02 16:55:00      阅读:221      评论:0      收藏:0      [点我收藏+]

标签:

UIView *oneSubView = [[UIView alloc] init];
oneSubView.frame = CGRectMake(50, 50, 100, 100);

UIView *twoSubView = [[UIView alloc] init];
twoSubView.frame = CGRectMake(50, 200, 20, 20);

UIView *threeSubView = [[UIView alloc] init];
threeSubView.frame = CGRectMake(200, 200, 50, 50);

[self.view batchAddSubview:oneSubView, twoSubView, threeSubView, nil];
// or
// [self.view batchAddSubviews:@[oneSubView, twoSubView, threeSubView]];

技术分享

不需要随机色调试, 可以在.m文件中, 注释掉下面该行代码即可: [(UIView *)obj setBackgroundColor:RandomColor];

GitHub: https://github.com/tomatoK/UIView-Extension

iOS 实用Category, 批量增加子视图

标签:

原文地址:http://www.cnblogs.com/oumygade/p/4930265.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!