简体   繁体   中英

Dynamically use UIViewContentModeScaleAspectFit and UIViewContentModeScaleAspectFill

I am trying to display images on the iPhone in the same way that the Photo app does. It seems to be able to dynamically select UIViewContentModeScaleAspectFit or UIViewContentModeScaleAspectFill depending on what is appropriate for the image. Where possible I would like images to appear full screen but if not then I would like them to appear UIViewContentModeScaleAspectFit

When you have an image check the size of the image, and then have a test or something.

if (imageSize > screenSize){
   imageView.contentMode = UIViewContentModeScaleAspect..
}else{
   imageView.contentMode = UIViewContentModeScaleAspect...
}

Hope this helps! Tams

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