I want to hide my Splash_View In Page curl Style, so that it can move to another class.
Default.png
Any Idea or suggestion from experts would be welcome.
Try this code:
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:2.0];
[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:self.window cache:YES];
[UIView commitAnimations];
Splash_Image_View.hidden = YES;
You'll need to make the splash image part of the main view to animate it. In your main view controller, set up an IBOutlet for a UIImageView, I'll call it splashImageView. In the MainWindow.xib file, drag in a UIImageView with your splash image on it and hook it up to the outlet. Then in the viewDidAppear of your main view controller .m file, you'll need to do something like this:
[UIView transitionWithView:self.view duration:0.5 options:UIViewAnimationOptionTransitionCurlUp animations:^{
splashImageView.hidden = YES;
} completion:NULL];
This will hide the splash view with a curl animation.
The simplest solution comes to mind is to load the same picture in your first [ViewDidLoad] and then doing something like this:
[UIView transitionWithView:self.view duration:0.4
delay:0.0
options:UIViewAnimationOptionTransitionCurlUp
animations:^{
//hide splash here
}
completion:^(BOOL finished){
}];
Related
I have a UIView drawn in Storyboard which holds some buttons and which is called viewHolder.
I get a higher position rectForAnimationBefore
and a lower position rectForAnimationAfter
[UIView animateWithDuration:1.0
delay:0.0
options:UIViewAnimationOptionCurveEaseInOut
animations:nil completion:^(BOOL finish){
[self.viewHolder setFrame:rectForAnimationAfter];
}];
when this is excuted,the viewHolder do move down.After a second,it comes up as nothing was done.
I want to moveDown,but don't want moveUp Automatically.
Because autolayout in Storyboard?
By the way ,how to move it smoothly?
Thank you guys.
UPDATE:
[UIView animateWithDuration:1.0
delay:0.0
options:UIViewAnimationOptionCurveEaseInOut
animations:^{
[self.viewHolder setFrame:rectForAnimationAfter];
}
completion:^(BOOL finish){
}];
when I change code like this ,I can't move it down .
Here is my solution
unlock the autolayout!!!
First thing your animation block is nil. Here you should move your view down. At completion you are setting back you view without using any animation. For smoothness you need to move back your view animatedly.
What is the simplest way to create a custom UIView animation transition? Most of the tutorials that pop up in a Google search are not recent. (I'm using XCode 4.5 version) In my current iPhone app I have the following code for my screen transitions:
[UIView beginAnimations:#"View flip" context:nil];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationDuration:1.25];
[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:self.view cache:YES];
[UIView commitAnimations];
I want something unique instead of the 5 or 6 built-in transitions. Any ideas or suggestions on where to start?
I think this is what you are looking for:
[UIView animateWithDuration:0.3 animations:^{
//Move frame or transform view
}];
Inside that block you can put arbitrary animation code.
I am working on a storybook app, i want to do the page curl like in the following video.
Demo Video
Can anyone tell me how to do exactly like this.
Update:
I want this page curling to support iOS 4.3+. UIPageViewController will work only on iOS 6.
You might want to consider UIPageViewController. It is quite useful in creating apps which use page curling animations. Here is the documentations link.
You can make use of the UIView's animation effect for this. I guess this should help you
[UIView beginAnimations:#"Curl" context:nil];
[UIView setAnimationDuration:2.0];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:contentView cache:YES];
[UIView commitAnimations];
where the contentView is the view where you are applying the animation. By varying the duration and animation curve you can modify your animation effect.
There are two ways of doing it:
The hard way, implement everything yourself (from scratch, with layers and masks and transforms and gradients) and a lot of headache.
the Easy way, read the documentation for UIPageViewController as suggested by #Zen. Its very useful and gives you the exact animation that you want (as shown in video). Or, using some third party code.
If you dont't have time constraint, then I will say, go the first way. You will learn a lot.
Cheers, have fun :)
EDIT
Here is the link to a sample app:
https://www.dropbox.com/s/x4qo2igrzvnkj16/CurlAnimationProject.zip
check it and tell me what you think.
SettingViewController *svc = [[SettingViewController alloc]initWithNibName:#"SettingViewController" bundle:nil];
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:2];
[UIView setAnimationCurve:UIViewAnimationCurveEaseIn];
[self.navigationController pushViewController:svc animated:YES];
[UIView setAnimationTransition:UIViewAnimationTransitionCurlDown forView:self.navigationController.view cache:NO];
[UIView commitAnimations];
As mentioned several time in the answers the UIPageViewController (apple documentation) is the thing you should be looking at.
The implementation is fairly straightforward, the controller uses 2 delegates
datasource : controlling the content to display (your pages) through 2 main methods
delegate : controlling its behaviour
It implements the swipe gesture for scrolling from page to page and can feature a page control at the bottom of your view.
For transitioning from page to page, you can either set a scroll animation (nice for photo / portfolios type) or the page curl you are looking for.
You can make page curl/flip effect by
For landscape mode:
[UIView beginAnimations:#"Curl" context:nil];
[UIView setAnimationDuration:2.0];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:contentView cache:YES];
[UIView commitAnimations];
For portrait mode:
[UIView beginAnimations:#"Curl" context:nil];
[UIView setAnimationDuration:2.0];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationTransition:UIViewAnimationTransitionCurlLeft forView:contentView cache:YES];
[UIView commitAnimations];
In my -application:DidFinishLaunchingWithOptions, as the final part, I have this code:
[UIView animateWithDuration:1 delay:1 options:UIViewAnimationOptionCurveEaseOut
animations:^{
[UIView setAnimationTransition:UIViewAnimationTransitionCurlDown forView:self.viewController.source cache:YES];
self.viewController.source.alpha = 1.0;
} completion:nil];
What it should do is "fade in the 'source' view and curl it down to cover the background"
Instead it just fades in the 'source' view, no curl.
Clues?
Solved:
It appears that parts of the animation loop isn't yet running at that point. Solution was to put the animation in a method, then from the application:DidFinishLaunchingWithOptions do
Having a puzzling problem. I have a universal app with a lot of shared code between the iPad and iPhone versions. There are different layouts in the nibs but essentially the same views and view hierarchy - one UIView used as a container for two sibling UITextViews.
UIView mainView with children:
UITextView passageTextView
UITextView notesTextView
One UITextView is hidden, the other visible.
The following is my code. The section commented out was my original animation attempt. This worked just as desired on the iPad, but not on the iPhone. The uncommented section is take 2, using the method recommended in the docs. The uncommented code does not work on either the iPad or iPhone - it hides/unhides my views but without any animation. If I add code to the completion block that also gets executed, so it's doing something, just not animating.
/*
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1.0];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:mainView cache:YES];
passageTextView.hidden = YES;
notesTextView.hidden = NO;
[UIView commitAnimations];
*/
UIViewAnimationOptions options = UIViewAnimationOptionBeginFromCurrentState | UIViewAnimationTransitionFlipFromRight;
[UIView transitionWithView:mainView
duration:1.0
options:options
animations:^{ passageTextView.hidden = YES; notesTextView.hidden = NO; }
completion:NULL];
Edit: Still working on the problem, hoping someone has a suggestion.
Additional update
Figured out why the following was not working in the iPhone:
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1.0];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:mainView cache:YES];
passageTextView.hidden = YES;
notesTextView.hidden = NO;
[UIView commitAnimations];
I had neglected to wire the view to mainView in Interface Builder. Hours debugging and I just now thought to check that.
But, I still do not know why animation blocks are not working for either the iPhone or iPad. I have tried several approaches but I'm not getting any animation even though the show/hides are working.
I think you are using the wrong animation option.
Replace your second animation option by UIViewAnimationOptionTransitionFlipFromLeft (note the Option between Animation and Transition)
I believe that UIViewAnimationTransitionFlipFromLeft (which is what you have in your code) is a UIViewAnimationTransition not a UIViewAnimationOptions.