Eureka 使用 Swift 以寄存器形式处理验证码行。
我插入了一个 TextRow 并将验证码图像分配给 cell.imageView
,但图像略高,覆盖了行线。如何更改该图像的高度?
尝试了 cell.imageView?.frame
,但没有用。
代码如下。非常感谢。
<<< TextRow(){ row in
row.title = ""
row.tag = "Captcha"
}.cellSetup { cell, row in
cell.imageView?.image = UIImage(data:imgData!, scale:1)
//this line is not working
cell.imageView?.frame = CGRect(x: 0, y: 0, width: 98, height: 28)
}
最佳答案
尝试使用预期高度调整 imageView 的大小
cell.imageView?.image = self.resizeImage(image: UIImage(data:imgData!, scale:1), expectedHeight: 28)
func resizeImage(image: UIImage, expectedHeight: CGFloat) -> UIImage
{
var image = image
let scale = expectedHeight / image.size.height
let newWidth = image.size.width * scale
UIGraphicsBeginImageContext(CGSize(width :newWidth, height : expectedHeight))
image.draw(in: CGRect(x: 0, y: 0, width: newWidth, height: expectedHeight))
image = UIGraphicsGetImageFromCurrentImageContext()!
UIGraphicsEndImageContext()
return image
}
关于ios - 在 Eureka TextRow 中更改 UIImageView 的高度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43932333/