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 12-30-2011, 06:06 PM   #1 (permalink)
Registered Member
 
Join Date: Dec 2010
Posts: 6
Endroits1 is on a distinguished road
Default UIView and UIImageView Bounds Masking

I'm working on a project for school where I will be having two images (a background and a foreground). The end goal will be that when you pan with your finger the foreground image will hide it self line by line, rather then pushing it off screen, displaying the image below. Kind of like this picture.

http://postimage.org/image/3oowvdvrl/

I am working on just the masking part as of now using the cliptobounds as the thing clipping the view.

The problem I am having right now is getting the view to clip from the left side rather then clipping from the middle. Like the photo below.

http://postimage.org/image/tvbv2qsyj

Is there a way to get it to clip from the left side rather then even out the clipping on each side? Also is calling cliptobounds the best way to do this panning and hiding the image?

Thanks for the help!


Code:
 [super viewDidLoad];

bottomView.autoresizesSubviews = NO;
CGRect screenBounds = [[UIScreen mainScreen] bounds];

CGPoint pointFrame = CGPointMake(0, 0);
CGSize sizeFrame= CGSizeMake(100, 100);

CGPoint pointBound = CGPointMake(0, 0);
CGSize sizeBound= CGSizeMake(0, 0);


CGFloat subtraction = 50.0;
pointBound.x = 0.0 ;
pointBound.y = 0.0;
sizeBound.width =  screenBounds.size.width - subtraction;
sizeBound.height = screenBounds.size.height;


pointFrame.x = 0.0-subtraction;
pointFrame.y = 0.0;
sizeFrame.width = screenBounds.size.width;
sizeFrame.height = screenBounds.size.height;



CGRect rectBound = CGRectMake(pointBound.x, pointBound.y, sizeBound.width, sizeBound.height); 
//CGRect rectFrame = CGRectMake(pointFrame.x, pointFrame.y, sizeFrame.width, sizeFrame.height);

bottomView.backgroundColor = [UIColor orangeColor];
//imageView.frame = rectFrame;
bottomView.bounds = rectBound;
//imageView.layer.anchorPoint = CGPointMake(0, 0.5);

bottomView.clipsToBounds = YES;
//bottomView.center = CGPointMake(150,200 );
bottomView.hidden = NO;
imageView.hidden = NO;
Endroits1 is offline   Reply With Quote
Old 12-30-2011, 08:15 PM   #2 (permalink)
JRG
[Cocoa] Developer
 
Join Date: Dec 2011
Posts: 15
JRG is on a distinguished road
Default Why Not Use UIPanGesture?

How about adding a UIPanGestureRecognizer on the foreground image? This way, the user would be able to pan (drag) the image off the screen? Perhaps, once it gets to a certain point on the right, the image would go completely off the screen?

Also, if the app is allowed to be rotated, be careful because your code below will break:

Code:
CGRect screenBounds = [[UIScreen mainScreen] bounds];
In such, the screen bounds don't care about orientation... checkout this post for a fairly simple fix using a category:

ios - How to get orientation-dependent height and width of the screen? - Stack Overflow

Good luck. : )
JRG is offline   Reply With Quote
Reply

Bookmarks

Tags
cliptobounds, uiimageview and uiimage, uiview

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: 398
14 members and 384 guests
7twenty7, AppsBlogger, comicool, Creativ, Dalia, dansparrow, Duncan C, HemiMG, heshiming, LunarMoon, Murphy, pbart, teebee74, Tomsky
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,676
Threads: 94,127
Posts: 402,915
Top Poster: BrianSlick (7,990)
Welcome to our newest member, jleannex55
Powered by vBadvanced CMPS v3.1.0

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