Mansonry2023-03-17

2023-03-16  本文已影响0人  iOS打怪升级

####### 图片添加比例约束

### 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);
        }];      
        
上一篇 下一篇

猜你喜欢

热点阅读