Get width of a resized image after UIViewContentModeScaleAspectFit

前端 未结 6 1655
忘了有多久
忘了有多久 2021-01-30 13:56

I have my UIImageView and I put an image into it that I resize like this:

UIImageView *attachmentImageNew = [[UIImageView alloc] initWithFrame:CGRectMake(5.5, 6.         


        
6条回答
  •  南笙
    南笙 (楼主)
    2021-01-30 14:36

    A solution in Swift:

    let currentHeight = imageView.bounds.size.height
    let currentWidth = imageView.bounds.size.width
    let newWidth = UIScreen.mainScreen().bounds.width
    let newHeight = (newWidth * currentHeight) / currentWidth
    
    println(newHeight)
    

提交回复
热议问题