设置控件不随父控件的拉伸而拉伸
2017-08-09 本文已影响0人
Rayla_周周
方法一
取消auto layout设置
步骤:
1. 在xib中选择控件 -> Interface Builder Document -> User Auto Layout 和 Use Trait Variations 选择去掉
2. Autoresizing中的多余线去除


方法二
- (void)awakeFromNib {
[super awakeFromNib];
// 设置控件不随父控件的拉伸而拉伸
self.autoresizingMask = UIViewAutoresizingNone;
}
设置控件frame随父控件的frame变化而变化
self.view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
-- UIViewAutoresizing为位移枚举,可以设置多个值,每个值之间用“|”分隔