美文网首页
Mansonry2023-03-17

Mansonry2023-03-17

作者: iOS打怪升级 | 来源:发表于2023-03-16 18:31 被阅读0次

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

    ### 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);
            }];      
            
    

    相关文章

      网友评论

          本文标题:Mansonry2023-03-17

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