AutoLayout I

来源:互联网 发布:普通电脑装mac系统 编辑:程序博客网 时间:2024/05/18 01:47

//更新xib中约束的值

@interface HistoryMainViewController ()

@property (weak, nonatomic) IBOutletNSLayoutConstraint *lbl_cal_trailing;

@end


@implementation HistoryMainViewController

// 更新约束

- (void)updateViewConstraints{

    [superupdateViewConstraints];

    

    if (Model_style ==ModelStyleSleep) {

        self.lbl_cal_trailing.constant =0;

    }elseif (Model_style ==ModelStyleSport){

        self.lbl_cal_trailing.constant = -40;

    }

}

@end





[bgView_ mas_makeConstraints:^(MASConstraintMaker *make) {

        make.leading.equalTo(self.view.mas_leading).with.offset(0);

        make.top.equalTo(self.view.mas_top).with.offset(0);

        make.height.mas_equalTo(SCREEN_HEIGHT);

        make.width.mas_equalTo(SCREEN_WIDTH);

    }];

    

    // logoView

    [logoView_ mas_makeConstraints:^(MASConstraintMaker *make) {

        make.centerX.mas_equalTo(self.view.mas_centerX);

        make.top.equalTo(self.view.mas_top).with.offset(50);

        make.height.mas_equalTo(SCREEN_HEIGHT *0.24);

        make.width.mas_equalTo(SCREEN_HEIGHT *0.24 * 1.14);

    }];

    

    int loginViewHeight = SCREEN_HEIGHT * 0.14;

    // loginView

    [loginView_ mas_makeConstraints:^(MASConstraintMaker *make) {

        make.leading.equalTo(self.view.mas_leading).with.offset(0);

        make.trailing.equalTo(self.view.mas_trailing).with.offset(0);

        make.height.mas_equalTo(loginViewHeight);

        make.top.equalTo(logoView_.mas_bottom).with.offset(SCREEN_HEIGHT * 0.08);

    }];

    // user

    [userView_ mas_makeConstraints:^(MASConstraintMaker *make) {

        make.top.equalTo(loginView_.mas_top).with.offset(loginViewHeight / 4 - 10);

        make.leading.equalTo(loginView_.mas_leading).with.offset(30);

        make.width.mas_equalTo(23);

        make.height.mas_equalTo(22);

    }];

    [userText_ mas_makeConstraints:^(MASConstraintMaker *make) {

        make.top.equalTo(userView_.mas_top).with.offset(0);

        make.leading.equalTo(userView_.mas_trailing).with.offset(15);

        make.width.mas_equalTo(250);

        make.height.mas_equalTo(22);

    }];

    // seperateLabel

    [sepLabel_ mas_makeConstraints:^(MASConstraintMaker *make) {

        make.centerX.mas_equalTo(self.view.mas_centerX);

        make.top.equalTo(loginView_.mas_top).with.offset(loginViewHeight / 2);

        make.leading.equalTo(loginView_.mas_leading).with.offset(20);

        make.height.mas_equalTo(1);

    }];

    // password

    [pwdView_ mas_makeConstraints:^(MASConstraintMaker *make) {

        make.top.equalTo(loginView_.mas_top).with.offset(loginViewHeight * 0.75 - 10);

        make.leading.equalTo(userView_.mas_leading).with.offset(0);

        make.width.mas_equalTo(23);

        make.height.mas_equalTo(22);

    }];

    [pwdText_ mas_makeConstraints:^(MASConstraintMaker *make) {

        make.top.equalTo(pwdView_.mas_top).with.offset(0);

        make.leading.equalTo(pwdView_.mas_trailing).with.offset(15);

        make.width.mas_equalTo(250);

        make.height.mas_equalTo(22);

    }];

    

    // forgotPwdButton

    [forgotPwdBtn_mas_makeConstraints:^(MASConstraintMaker *make) {

        make.trailing.equalTo(self.view.mas_trailing).with.offset(25);

        make.top.equalTo(loginView_.mas_bottom).with.offset(8);

        make.width.mas_equalTo(160);

        make.height.mas_equalTo(20);

    }];

    

    // loginButton

    [loginBtn_ mas_makeConstraints:^(MASConstraintMaker *make) {

        make.leading.equalTo(self.view.mas_leading).with.offset(0);

        make.trailing.equalTo(self.view.mas_trailing).with.offset(0);

        make.height.mas_equalTo(SCREEN_HEIGHT *0.07);

        make.top.equalTo(loginView_.mas_bottom).with.offset(SCREEN_HEIGHT * 0.08);

    }];

    

    //loginTipsView

    [loginTipsView_mas_makeConstraints:^(MASConstraintMaker *make) {

        make.centerX.mas_equalTo(self.view.mas_centerX);

        make.top.equalTo(loginBtn_.mas_bottom).with.offset(SCREEN_HEIGHT * 0.04 + 8);

        make.leading.equalTo(self.view.mas_leading).with.offset(20);

        make.height.mas_equalTo(1);

    }];

    

    // loginTipsLabel

    [loginTipsLbl_mas_makeConstraints:^(MASConstraintMaker *make) {

        make.centerX.mas_equalTo(self.view.mas_centerX);

        make.top.equalTo(loginBtn_.mas_bottom).with.offset(SCREEN_HEIGHT * 0.04);

        make.width.mas_equalTo(160);

        make.height.mas_equalTo(16);

    }];

    

    // qqButton

    [qqBtn_ mas_makeConstraints:^(MASConstraintMaker *make) {

        make.top.equalTo(loginTipsLbl_.mas_bottom).with.offset(SCREEN_HEIGHT * 0.05);

        make.leading.equalTo(self.view.mas_leading).with.offset(SCREEN_WIDTH * 0.28);

        make.width.mas_equalTo(30);

        make.height.mas_equalTo(30);

    }];

    

    // weixinButton

    [wxBtn_ mas_makeConstraints:^(MASConstraintMaker *make) {

        make.top.equalTo(loginTipsLbl_.mas_bottom).with.offset(SCREEN_HEIGHT * 0.05);

        make.trailing.equalTo(self.view.mas_trailing).with.offset(-SCREEN_WIDTH * 0.28);

        make.width.mas_equalTo(30);

        make.height.mas_equalTo(30);

    }];

    

    // registView

    [registView_ mas_makeConstraints:^(MASConstraintMaker *make) {

        make.centerX.mas_equalTo(self.view.mas_centerX);

        make.top.equalTo(qqBtn_.mas_bottom).with.offset(SCREEN_HEIGHT * 0.04);

        make.width.mas_equalTo(165);

        make.height.mas_equalTo(30);

    }];

0 0
原创粉丝点击