Code X 轴中心对齐,相当于确定了 X 值,给定控件的宽度,然后进行约束,相等
UIImageView *iconImg = [[UIImageView alloc] init];
iconImg.backgroundColor = [UIColor clearColor];
[iconImg setImage:[UIImage imageNamed:@"icon"]];
[self.view addSubview:iconImg];
[iconImg mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(weakSelf.view).offset(100);
make.width.equalTo(@70);
make.height.equalTo(iconImg.mas_width);
make.centerX.mas_equalTo(self.view.mas_centerX);
}];