storyboard,个人觉得是个好玩意儿,但是什么都做到其中总觉得杂乱。个人偏好把复杂的局部控件(比如定制的collectionviewcell)在xib文件中拉好。
在开发过程中遇到不少坑,记忆犹新的是:xib中的部件(比如button)设置圆角的效果不对;加载的xib不能resize大小。
view.layer.cornerRadius = view.frame.size.height / 2;
- (void)viewDidLayoutSubviews;
-layoutSubviews;
[xib layoutIfNeeded]
- (void)awakeFromNib { [super awakeFromNib]; //solve UICollectionViewCell subviews do not resize self.contentView.autoresizingMask = //UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleWidth | //UIViewAutoresizingFlexibleRightMargin | //UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleHeight //UIViewAutoresizingFlexibleBottomMargin ; self.contentView.translatesAutoresizingMaskIntoConstraints = YES; }
原文地址:http://blog.csdn.net/wusoule/article/details/45624469