Quote:
Originally Posted by cybohemia
I would like to show only part of an image and then smoothly reveal the entire image, as shown:
I've seen some postings on how to crop images but I don't want a permanent crop since I only want to hide parts temporarily and cropping could be expensive as well as cause problems when I want to align it the the full image.
I also got a solution that would work but only if the image were not offset. As shown in the illustration, I will want to offset the image (like, to only show the eyes).
Would anyone have any ideas how this could be done?
Thanks!
|
Off the top of my head:
Put your image in a UIImageView.
Make the UIImageView a subview of a smaller view, and set the parent view's clipsToBounds property to true.
Your image view should now be drawn cropped inside it's parent view. If you change the center property of the image view, you can move around the part that's shown. If you adjust the size of the frame of the parent view, you can expose more of the cropped image view.
As long as you don't change the parent view's transform property, you should be able to animate changes to it's frame property to shift it down as you expose more of the image subview. (Use the UIView animation class methods. They are really, really easy to use. Or use the new block-based view animation methods if your app is targeted to >= iOS 4.0).
I haven't done this particular bit of animation before, but I think it should work. Give it a try.