佚名通过本文主要向大家介绍了ios 基础控件,ios ui控件,ios10控件,ios时间控件,ios控件等相关知识,希望对您有所帮助,也希望大家支持linkedu.com www.linkedu.com
问题:iOS基础控件 iOS 同事写的创建代码的形式有点不认识
描述:
解决方案1:
描述:
同事写的创建控件的代码形式有点不认识...是masonry的特殊形式?
UIButton * button = ({
button = [[UIButton alloc] init];
button.backgroundColor = [UIColor lightGrayColor];
[button setTitle:@"button" forState:UIControlStateNormal];
[button addTarget:self action:@selector(button:) forControlEvents:UIControlEventTouchUpInside];
button.layer.cornerRadius = 30.f;
button.layer.masksToBounds = YES;
[_bottomView addSubview:button];
[button mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerY . equalTo (button.mas_centerY);
make.right . equalTo (button.mas_left).offset(-10);
make.width . equalTo (@(60));
make.height . equalTo (@(60));
}];
button;
});
解决方案1:
这个就是 masonry,好像没什么特殊的呀?只是空格空得有点特殊……
解决方案2:是一种比较特殊的表达式而已,具体看
小括号内联复合表达式: http://blog.sunnyxx.com/2014/08/02/objc-weird-code/