美文网首页
两个Label文字底部对齐的问题

两个Label文字底部对齐的问题

作者: TsingQue | 来源:发表于2017-11-03 16:39 被阅读190次

有个需求是这个样子的


WX20171103-163802@2x.png

然后觉得直接慢慢微调这俩Label的大小好了.....

然后时间比较充足的时候,考虑了下,可以使用如下

    label1.font = [UIFont systemFontOfSize:30];
    label1.backgroundColor = [UIColor purpleColor];
    label1.text = @"100元/个";
    label1.textColor = [UIColor redColor];
    [label1 sizeToFit];
    [self.view addSubview:label1];
    [label1 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.view).offset(10);
        make.top.equalTo(self.view).offset(300);
    }];

    UILabel *label2 = [[UILabel alloc] init];
    label2.font = [UIFont systemFontOfSize:26];
    label2.text = @"这是什么鬼";
    label2.textColor = [UIColor greenColor];
    label2.backgroundColor = [UIColor purpleColor];
    [label2 sizeToFit];
    [self.view addSubview:label2];
    [label2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(label1.mas_right).offset(10);
        make.bottom.equalTo(label1).offset(0);
    }];

over.可以使用

相关文章

网友评论

      本文标题:两个Label文字底部对齐的问题

      本文链接:https://www.haomeiwen.com/subject/lgwtmxtx.html