gpt4 book ai didi

ios - 在 Eureka TextRow 中更改 UIImageView 的高度

转载 作者:行者123 更新时间:2023-11-28 08:10:22 26 4
gpt4 key购买 nike

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)
}

screen shot

最佳答案

尝试使用预期高度调整 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/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com