标签:
/*关于autolayout多说几句
* 在一个控件内存在autolayout与autoresize子控件时,要适配部分autoresize
* translatesAutoresizingMaskIntoConstraints 默认是打开转换的
//在autoresize下可以通过以下代码进行autolayout视图的大小计算
if (!contentView.translatesAutoresizingMaskIntoConstraints) {
[contentView needsUpdateConstraints];
[contentView updateConstraints];
CGSize ss = [contentView systemLayoutSizeFittingSize:UILayoutFittingCompressedSize];
}
//另外如果autolayout视图在autoresize视图内部,而且需要配置相对位置,可以通过以下代码设置
[autoresizeView removeConstraints:autoresizeView.constraints];//或者只删除配置内容相关的
NSDictionary *dic = NSDictionaryOfVariableBindings(autolayout);
NSString *VFL = [NSString stringWithFormat:@"V:|-%f-[autolayout]",rect.origin.y];
NSArray *ar = [NSLayoutConstraint constraintsWithVisualFormat:VFL options:0 metrics:nil views:dic];
[autoresizeView addConstraints:ar];
VFL = [NSString stringWithFormat:@"|-%f-[autolayout]",rect.origin.x];
ar = [NSLayoutConstraint constraintsWithVisualFormat:VFL options:0 metrics:nil views:dic];
[autoresizeView addConstraints:ar];
*/
还有一种办法在外面进行计算,给autolayout的视图加个UIView壳,systemLayoutSizeFittingSize:计算出大小设置到壳上,再放到非autolayout支持的视图上
标签:
原文地址:http://my.oschina.net/u/816791/blog/386080