即宽度不够时候,拉升到屏幕宽度,然后保持宽高比不变:
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) } }
即宽度不够时候,拉升到屏幕宽度,然后保持宽高比不变:
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) } }