The Paper Folding/Unfolding Effect in Twitter for iPad

the paper folding/unfolding effect in twitter for iPad

Here's a really simple example using a gesture recognizer and CATransform3D to get you started. Simply pinch to rotate the gray view.

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// ...

CGRect rect = self.window.bounds;
view = [[UIView alloc] initWithFrame:CGRectMake(rect.size.width/4, rect.size.height/4,
rect.size.width/2, rect.size.height/2)];
view.backgroundColor = [UIColor lightGrayColor];
[self.window addSubview:view];

CATransform3D transform = CATransform3DIdentity;
transform.m34 = -1/500.0; // this allows perspective
self.window.layer.sublayerTransform = transform;

UIPinchGestureRecognizer *rec = [[UIPinchGestureRecognizer alloc] initWithTarget:self
action:@selector(pinch:)];
[self.window addGestureRecognizer:rec];
[rec release];

return YES;
}

- (void)pinch:(UIPinchGestureRecognizer *)rec
{
CATransform3D t = CATransform3DIdentity;
t = CATransform3DTranslate(t, 0, -self.view.bounds.size.height/2, 0);
t = CATransform3DRotate(t, rec.scale * M_PI, 1, 0, 0);
t = CATransform3DTranslate(t, 0, -self.view.bounds.size.height/2, 0);
self.view.layer.transform = t;
}

iOS Paper fold (origami / accordion) effect animation, with manual control

I write another library for folding transition : https://github.com/geraldhuard/YFoldView

Hope it works for you.

Animation on the IPad - What to use for something like the Alice in Wonderland Book?

A popular framework is cocos-2d for iOS which you can use to build something like the Alice book.

iPad - How to move Mulitple UIViews side-by-side

You should take a look at the UIScrollView with paging enabled.

Make all your views and put them next to one another inside a UIScrollView. i.e.

// Get your views
MyView *v1 = [[[MyView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)] autorelease];
MyView *v2 = [[[MyView alloc] initWithFrame:CGRectMake(320, 0, 320, 480)] autorelease];
MyView *v3 = [[[MyView alloc] initWithFrame:CGRectMake(640, 0, 320, 480)] autorelease];

// Make the UIScrollView
UIScrollView *scroll = [[[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)] autorelease];
[scroll setPagingEnabled:YES];
[[scroll addSubview:v1];
[[scroll addSubview:v2];
[[scroll addSubview:v3];
[scroll setContentSize:CGSizeMake(960, 480)];

// add the scroll view to your view
[[self view] addSubview:scroll];

Now, the three views (v1, v2 and v3) are next to each other in a scroll view whose content is much wider the view. With paging enabled, they will scroll left and right but won't stop halfway through a view.

3D Door Open Animation between two UIViewControllers

You have to apply a little trick to get 3D to work:

CATransform3D _3Dt = CATransform3DIdentity;
_3Dt.m34 = 1.0 / -1000;

This creates perspective transform. 1000 represents the distance from the viewer to the objects (you can experiment with this value to get a smooth look).



Related Topics



Leave a reply



Submit