####### 图片添加比例约束
### make.height.equalTo(_imgView.mas_width).multipliedBy(ratio);
_imgView = [[UIImageView alloc] initWithImage:[GlobalBundle imageForName:@"airplay_guide_img"]];
[_imgView setContentMode:UIViewContentModeScaleAspectFill];
float ratio = _imgView.image.size.height/_imgView.image.size.width;
[self.scrollview addSubview:_imgView];
[_imgView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self).offset(22);
make.right.equalTo(self).offset(-22);
///比例约束
make.height.equalTo(_imgView.mas_width).multipliedBy(ratio);
make.top.mas_equalTo(16);
make.bottom.mas_equalTo(-20);
}];
网友评论