How to set the image into fit screen in the image view

[亡魂溺海] 提交于 2020-01-17 03:32:24

问题


I am new to iphone development. I want to display the actual size of the image in image view. I have created image view by using Interface builder and set the properties. Now the problem is, I have set into "Scale to Fill", then the image will be stretched in the full screen. Now i want to display the actual size of the image will be displayed in image view. For example 52X52 size image should be displayed with the same size in the image view.The 1200X1020 size image should be fit to the size of the image view .So according the size of the image it should fit to image view and i want the image smaller than image view should retain its original size(It should not stretch to fit the image view). Is it any possible solution to achieve it, please guide me.

Thanks.


回答1:


You're going to have to check the dimensions on the UIImage yourself and then set the proper property on the UIImageView: myImage.contentMode = UIViewContentModeCenter , etc

The different content modes: http://developer.apple.com/iphone/library/documentation/UIKit/Reference/UIView_Class/UIView/UIView.html#//apple_ref/c/econst/UIViewContentModeScaleToFill



来源:https://stackoverflow.com/questions/2510807/how-to-set-the-image-into-fit-screen-in-the-image-view

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!