您的位置:首页 > 其它

Masonry手码布局

2016-01-31 19:48 330 查看
//底部背景

UIView *view = [[UIView
alloc] init];

view.backgroundColor = [UIColor
whiteColor];

[view mas_makeConstraints:^(MASConstraintMaker *make) {

        make.size.mas_equalTo(CGSizeMake(WJScreenWidth,
180));

        make.left.equalTo(cover).with.offset(0);  

        make.right.equalTo(cover).with.offset(0);

        make.bottom.equalTo(cover).with.offset(0);

    }];

//标题

    UILabel *titleLabel = [[UILabel
alloc] init];

    titleLabel.text =
@"交易类型";

    titleLabel.font = [UIFont
systemFontOfSize:17.0];

    [titleLabel setTextColor:[UIColor
blackColor]];

    //分割线

    UIView *divideLine = [[UIView
alloc] init];

    [divideLine setBackgroundColor:WJAppTransactionDivideColor];

    //全部

    UIButton *allBtn = [[UIButton
alloc] init];

    [allBtn setTitle:@"全部"
forState:UIControlStateNormal];

    allBtn.titleLabel.font = [UIFont
systemFontOfSize:14.0];

    [allBtn setTitleColor:[UIColor
blackColor] forState:UIControlStateNormal];

    [allBtn setTitleColor:[UIColor
redColor] forState:UIControlStateSelected];

    [allBtn addTarget:self
action:@selector(clickAll:)
forControlEvents:UIControlEventTouchUpInside];

    //充值

    UIButton *rechargeBtn = [[UIButton
alloc] init];

    [rechargeBtn setTitle:@"充值"
forState:UIControlStateNormal];

     rechargeBtn.titleLabel.font = [UIFont
systemFontOfSize:14.0];

    [rechargeBtn setTitleColor:[UIColor
blackColor] forState:UIControlStateNormal];

    [rechargeBtn setTitleColor:[UIColor
redColor] forState:UIControlStateSelected];

    [rechargeBtn addTarget:self
action:@selector(clickRecharge:)
forControlEvents:UIControlEventTouchUpInside];

    //提现

    UIButton *withdrawlBtn = [[UIButton
alloc] init];

    [withdrawlBtn setTitle:@"提现"
forState:UIControlStateNormal];

     withdrawlBtn.titleLabel.font = [UIFont
systemFontOfSize:14.0];

    [withdrawlBtn setTitleColor:[UIColor
blackColor] forState:UIControlStateNormal];

    [withdrawlBtn setTitleColor:[UIColor
redColor] forState:UIControlStateSelected];

    [withdrawlBtn addTarget:self
action:@selector(clickWithdrawal:)
forControlEvents:UIControlEventTouchUpInside];

    //撤资回款

    UIButton *withdrawInterestPaymentBtn = [[UIButton
alloc] init];

    [withdrawInterestPaymentBtn setTitle:@"撤资回款"
forState:UIControlStateNormal];

     withdrawInterestPaymentBtn.titleLabel.font = [UIFont
systemFontOfSize:14.0];

    [withdrawInterestPaymentBtn setTitleColor:[UIColor
blackColor] forState:UIControlStateNormal];

    [withdrawInterestPaymentBtn setTitleColor:[UIColor
redColor] forState:UIControlStateSelected];

    [withdrawInterestPaymentBtn addTarget:self
action:@selector(clickWithdrawInterestPayment:)
forControlEvents:UIControlEventTouchUpInside];

    //购买理财

    UIButton *buyFinancialBtn = [[UIButton
alloc] init];

    [buyFinancialBtn setTitle:@"购买理财"
forState:UIControlStateNormal];

     buyFinancialBtn.titleLabel.font = [UIFont
systemFontOfSize:14.0];

    [buyFinancialBtn setTitleColor:[UIColor
blackColor] forState:UIControlStateNormal];

    [buyFinancialBtn setTitleColor:[UIColor
redColor] forState:UIControlStateSelected];

    [buyFinancialBtn addTarget:self
action:@selector(clickBuyFinancial:)
forControlEvents:UIControlEventTouchUpInside];

    //本息回款

    UIButton *thePrincipalAndInterestPaymentBtn = [[UIButton
f208

alloc] init];

    [thePrincipalAndInterestPaymentBtn setTitle:@"本息回款"
forState:UIControlStateNormal];

     thePrincipalAndInterestPaymentBtn.titleLabel.font = [UIFont
systemFontOfSize:14.0];

    [thePrincipalAndInterestPaymentBtn setTitleColor:[UIColor
blackColor] forState:UIControlStateNormal];

    [thePrincipalAndInterestPaymentBtn setTitleColor:[UIColor
redColor] forState:UIControlStateSelected];

    [thePrincipalAndInterestPaymentBtn addTarget:self
action:@selector(clickThePrincipalAndInterestPayment:)
forControlEvents:UIControlEventTouchUpInside];

    

    [view addSubview:titleLabel];

    [view addSubview:divideLine];

    [view addSubview:allBtn];

    [view addSubview:rechargeBtn];

    [view addSubview:withdrawlBtn];

    [view addSubview:withdrawInterestPaymentBtn];

    [view addSubview:buyFinancialBtn];

    [view addSubview:thePrincipalAndInterestPaymentBtn];

    

    [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {

        make.top.equalTo(view.mas_top).with.offset(15);

        make.centerX.equalTo(view.mas_centerX);

        make.height.equalTo(@20);

    }];

    [divideLine mas_makeConstraints:^(MASConstraintMaker *make) {

        make.top.equalTo(titleLabel.mas_bottom).with.offset(15);

        make.left.equalTo(view.mas_left).with.offset(0);

        make.right.equalTo(view.mas_right).with.offset(0);

        make.width.equalTo(view.mas_width).with.offset(0);

        make.height.equalTo(@1);

    }];

    [allBtn mas_makeConstraints:^(MASConstraintMaker *make) {

        make.top.equalTo(divideLine.mas_bottom).with.offset(0);

        make.left.equalTo(view.mas_left).with.offset(0);

        make.right.equalTo(rechargeBtn.mas_left).with.offset(0);

        make.bottom.equalTo(withdrawInterestPaymentBtn.mas_top).with.offset(0);

        make.height.equalTo(@90);

    }];

    [rechargeBtn mas_makeConstraints:^(MASConstraintMaker *make) {

        make.top.equalTo(divideLine.mas_bottom).with.offset(0);

        make.left.equalTo(allBtn.mas_right).with.offset(0);

        make.right.equalTo(withdrawlBtn.mas_left).with.offset(0);

        make.bottom.equalTo(buyFinancialBtn.mas_top).with.offset(0);

        make.width.equalTo(allBtn.mas_width).with.offset(0);

        make.height.equalTo(allBtn.mas_height).with.offset(0);

    }];

    [withdrawlBtn mas_makeConstraints:^(MASConstraintMaker *make) {

        make.top.equalTo(divideLine.mas_bottom).with.offset(0);

        make.left.equalTo(rechargeBtn.mas_right).with.offset(0);

        make.right.equalTo(view.mas_right).with.offset(0);

        make.bottom.equalTo(thePrincipalAndInterestPaymentBtn.mas_top).with.offset(0);

        make.width.equalTo(allBtn.mas_width).with.offset(0);

        make.height.equalTo(allBtn.mas_height).with.offset(0);

    }];

    [withdrawInterestPaymentBtn mas_makeConstraints:^(MASConstraintMaker *make) {

        make.top.equalTo(allBtn.mas_bottom).with.offset(0);

        make.left.equalTo(view.mas_left).with.offset(0);

        make.right.equalTo(buyFinancialBtn.mas_left).with.offset(0);

        make.bottom.equalTo(view.mas_bottom).with.offset(0);

        make.width.equalTo(allBtn.mas_width).with.offset(0);

        make.height.equalTo(allBtn.mas_height).with.offset(0);

    }];

    [buyFinancialBtn mas_makeConstraints:^(MASConstraintMaker *make) {

        make.top.equalTo(rechargeBtn.mas_bottom).with.offset(0);

        make.left.equalTo(withdrawInterestPaymentBtn.mas_right).with.offset(0);

        make.right.equalTo(thePrincipalAndInterestPaymentBtn.mas_left).with.offset(0);

        make.bottom.equalTo(view.mas_bottom).with.offset(0);

        make.width.equalTo(allBtn.mas_width).with.offset(0);

        make.height.equalTo(allBtn.mas_height).with.offset(0);

    }];

    [thePrincipalAndInterestPaymentBtn mas_makeConstraints:^(MASConstraintMaker *make) {

        make.top.equalTo(withdrawlBtn.mas_bottom).with.offset(0);

        make.left.equalTo(buyFinancialBtn.mas_right).with.offset(0);

        make.right.equalTo(view.mas_right).with.offset(0);

        make.bottom.equalTo(view.mas_bottom).with.offset(0);

        make.width.equalTo(allBtn.mas_width).with.offset(0);

        make.height.equalTo(allBtn.mas_height).with.offset(0);

    }];
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: