How to set size of UIImageView equal to size of UIImage?

前端 未结 1 1548
南旧
南旧 2021-01-16 09:19

I have an view controller with UIImageView named someImageView. This image view has no default UIImage. I\'m loading UIImage

相关标签:
1条回答
  • 2021-01-16 10:07

    You have to change contentMode to UIViewContentModeScaleToFill of your imageView

    someImageView.image = myImage;
    someImageView.contentMode = UIViewContentModeScaleToFill;
    
    CGRect frame = someImageView.frame;
    frame.size = myImage.size;
    someImageView.frame = frame;
    
    0 讨论(0)
提交回复
热议问题