Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 04-01-2011, 02:08 PM   #1 (permalink)
Registered Member
 
Join Date: Jan 2009
Posts: 48
cybohemia is on a distinguished road
Default Showing part of an image before showing full image

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!
cybohemia is offline   Reply With Quote
Old 04-01-2011, 03:58 PM   #2 (permalink)
Cocoa Junkie
 
Duncan C's Avatar
 
Join Date: Dec 2008
Location: Northern Virginia
Posts: 6,003
Duncan C has a spectacular aura about
Default

Quote:
Originally Posted by cybohemia View Post
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.
__________________
Regards,

Duncan C
WareTo

Check out our apps in the Apple App store


Check out this password generator app that shows various techniques including using a data container singleton object to share data between objects in your project.

See this tutorial on using UIView animations and layer animations:

See this thread on generating random, non-repeating text

Check out a very cool Macintosh Kaleidoscopes app called ScopeWorks that we released to the Mac App store.
Duncan C is offline   Reply With Quote
Old 04-02-2011, 12:33 PM   #3 (permalink)
Registered Member
 
Join Date: Jan 2009
Posts: 48
cybohemia is on a distinguished road
Default

I gave it a try and it worked like a charm! Thanks so much for the suggestion - by the time I posted, I had been going down the wrong path way too long to see any other possibilities and was baffled at how convoluted the solution was getting

Quote:
Originally Posted by Duncan C View Post
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.
cybohemia is offline   Reply With Quote
Old 04-02-2011, 08:18 PM   #4 (permalink)
Cocoa Junkie
 
Duncan C's Avatar
 
Join Date: Dec 2008
Location: Northern Virginia
Posts: 6,003
Duncan C has a spectacular aura about
Default

Quote:
Originally Posted by cybohemia View Post
I gave it a try and it worked like a charm! Thanks so much for the suggestion - by the time I posted, I had been going down the wrong path way too long to see any other possibilities and was baffled at how convoluted the solution was getting
Isn't this pretty much the exact same question you asked the day before?

http://www.iphonedevsdk.com/forum/ip...imageview.html

That's aggravating. Don't do that please.
__________________
Regards,

Duncan C
WareTo

Check out our apps in the Apple App store


Check out this password generator app that shows various techniques including using a data container singleton object to share data between objects in your project.

See this tutorial on using UIView animations and layer animations:

See this thread on generating random, non-repeating text

Check out a very cool Macintosh Kaleidoscopes app called ScopeWorks that we released to the Mac App store.
Duncan C is offline   Reply With Quote
Old 04-03-2011, 03:01 AM   #5 (permalink)
Registered Member
 
Join Date: Jan 2009
Posts: 48
cybohemia is on a distinguished road
Default

The two postings did overlap but there was one major difference: the displacement of the image is arbitrary. My attempt to reduce the problem for the sake of clarity over-simplified it and I needed to re-state it more generally. I'm sorry if you were aggravated particularly since your suggestion solved it for the general case I needed.

Quote:
Originally Posted by Duncan C View Post
Isn't this pretty much the exact same question you asked the day before?

http://www.iphonedevsdk.com/forum/ip...imageview.html

That's aggravating. Don't do that please.
cybohemia is offline   Reply With Quote
Reply

Bookmarks

Tags
cropping, image, resizing

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 374
12 members and 362 guests
condor304, dansparrow, dre, ilmman, LezB44, michelle, Objective Zero, samdanielblr, Sami Gh, shagor012, thephotographer, tinamm64
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,663
Threads: 94,119
Posts: 402,896
Top Poster: BrianSlick (7,990)
Welcome to our newest member, LezB44
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 01:39 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0