简体   繁体   中英

Change height of UIImageView in Eureka TextRow

Working on a captcha row in register form by Eureka with Swift. I inserted a TextRow and assign the captcha image to cell.imageView , but the image is slightly taller that covered the row line. How can I change the height of that image?

Tried cell.imageView?.frame , not working.

Codes below. Many thanks.

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

屏幕截图

Try to resize imageView using expected height

 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
        }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM