屏幕适配

屏幕适配

最外层View大小固定(不乘比例缩放值),里面的子控件使用AutoLayout(可以用Masonry来写布局约束)即可.

例如:UI在iphone5上给的一个View的切图是100 X 200

UIView *view = [[UIView alloc] init];
//父控件大小固定值,无需乘以缩放比例值
view.frame = CGRectMake(0,0,100,200);
//子控件需要使用AutoLayout
UILabel *label = [[UILabel alloc] init];
label = [[UILabel alloc] init];
    label.numberOfLines = 0;
    label.text = @"label";
    [self addSubview: label];
    [label setTextAlignment:(NSTextAlignmentCenter)];
    [label mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self).offset(23);
        make.centerX.equalTo(self);
}];

你可能感兴趣的:(屏幕适配)