用xib自定义UIView并在代码中使用--iOS
2016-08-13 12:01
423 查看
首先新建一个空的xib文件:
将size改为freedom:
然后在xib中自定义视图(添加自己想要的其它视图):
要写好约束, 创建一个继承uiview的类和他关联,然后就可以调用了.
将size改为freedom:
然后在xib中自定义视图(添加自己想要的其它视图):
要写好约束, 创建一个继承uiview的类和他关联,然后就可以调用了.
- (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib. //获得nib视图数组 NSArray *nibContents = [[NSBundle mainBundle] loadNibNamed:@"HeadView" owner:nil options:nil]; // Find the view among nib contents (not too hard assuming there is only one view in it). // 得到最后一个view HeadView *headView = [nibContents lastObject]; headView.frame = CGRectMake(0, 0, 300, 200); //headView.backgroundColor = [UIColor blueColor]; _tableView.tableHeaderView = headView; }
相关文章推荐
- IOS开发 使用XIB自定义一个UIView
- IOS开发 使用XIB自定义一个UIView
- IOS开发(97)之自定义视图之使用XIB自定义一个UIView
- IOS开发 使用XIB自定义一个UIView
- iOS使用xib自定义uiview
- IOS开发 使用XIB自定义一个UIView
- 设置视图IOS开发(97)之自定义视图之使用XIB自定义一个UIView
- iOS使用xib自定义UIView 遇到的问题
- iOS开发笔记22--使用XIB自定义一个UIView
- IOS使用XIB自定义UIView
- IOS开发 使用XIB自定义一个UIView
- [iOS 使用xib自定义UIView]
- iOS使用xib自定义uiview
- [讨论]iOS 开发之使用XIB/StoryBoard 和 使用代码
- [ios]如何通过XIB 创建自定义的UIViewTableCell
- iOS开发 自定义tableView样式(使用代码/使用Interface Builder)、分组显示、给TableView增加索引、给TableView增加SearchBar
- iOS开发UI篇—以微博界面为例使用纯代码自定义cell程序编码全过程(二)
- IOS成长之路-使用xib界面与和代码相关联的方法
- IOS成长之路-使用xib界面与和代码相关联的方法