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; }