Reputation: 73
I wonder if somebody here knows how I can slide the views in my application. When I'm in a view, I want to slide to another view like in "The Magazine". (see image)
Hope somebody can help me.
Image:
Upvotes: 1
Views: 417
Reputation: 104082
As far as I know, there is no "canned" transition that does a slide over. I've implemented it like this:
-(void)SlideInController:(RDSlideController *) next {
next.presentingVC = self;
next.view.frame = CGRectMake(self.view.frame.origin.x + 320, self.view.frame.origin.y, self.view.frame.size.width, self.view.frame.size.height);
[self.view.window addSubview:next.view];
[UIView animateWithDuration:slideTime animations:^{
next.view.frame = self.view.frame;
} completion:^(BOOL finished) {
self.view.window.rootViewController = next;
}];
}
-(void)SlideOut {
RDSlideController *prev = self.presentingVC;
prev.view.frame = self.view.frame;
[self.view.window insertSubview:prev.view belowSubview:self.view];
[UIView animateWithDuration:slideTime animations:^{
self.view.frame = CGRectMake(self.view.frame.origin.x + 320, self.view.frame.origin.y, self.view.frame.size.width, self.view.frame.size.height);
} completion:^(BOOL finished) {
self.view.window.rootViewController = prev;
}];
}
In this example, I made a controller class (RDSlideController) that was the superclass of my other controllers, so that they would all have the presentingVC property and access to the various slide in and out (and up and down) methods that I wrote. This should give you an idea of how to do this.
Upvotes: 1
Reputation: 21902
Take a look at UIPageViewController
Here is a link to the doc. Starting with iOS5, it supports the page curl transition. And in iOS6, they added the slide like you have on your screenshot.
If you need to support earlier version, you will most likely need to create your own animation (using CAAnimation
).
Upvotes: 0