ios中UIImageView如何宽度自适应

即宽度不够时候,拉升到屏幕宽度,然后保持宽高比不变:

iv.snp_makeConstraints { [unowned contentView] (make) in
     if let image = iv.image where image.size.width > 0 {
        make.height.equalTo(image.size.height * (screenWidth - CGFloat(padding * 2)) / image.size.width)
    }
}

 

Leave a Reply

Your email address will not be published.