开发者

Image "frame/window" on iphone

I have numerous photos in portrait and landscape format. I want to be able to display a "crop" of the photo in a UIImageView on the iphone. If the picture is in landscape format I want it to resize to fit the frame, if it is in portrait format I need it to resize to fit the width, and then be cropped at the top and bottom. As if t开发者_运维百科here is a "window" over the image - so it looks like a landscape picture.

It would be even better if this could be a UIButton - although I am aware that I can use touchesBegan and such on images to make it behave like a button if needs be.

Thanks for any help you can give me.

Thanks Tom


In an ImageView, you can change the View Mode to Aspect Fill. It will give you the right scaling/cropping you want.

For interactions, you can use a Custom button with no drawing at all (no Title, no Image, no Background) with the same size as your ImageView. That would be safe with regards to the image aspect. I've tried similar stuff using the button's Background or Image properties, it can have some undesired effects (I've ran into a resizing issue on iOS 3.1.3 for instance).


1°) To Crop the Image, try to add a method to UIImage class to do it (you can google it without problem, or even on StackOverFlow)

2°) To add a "window" over your image, just add an UIImageView over your image wich has transparency. It should work ;-)

3°) To know when an image is touched, you can use "touchesBegan" to detect which image were selected. But I think it's the last of your problems ^^

What you cant to achieve isn't so hard, just to it step by step ! If you want more help in one step, say it. But I can't code it all for you ;-)

Good Luck

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜