views:

22

answers:

2

Hi there.

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 there 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

A: 

Hello !

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

Vinzius
thanks for your comment. :) little bit vague though, didn't really help. nonetheless, thank you for your time. :)
Thomas Clayson
+1  A: 

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).

jv42
will try that thank you. :)
Thomas Clayson