I am trying to develop a simple CATransition that shows an UIView appearing from the left.
Here it is the code:
CATransition *transDerecha=[CATransition animation];
[transDerecha setDuration:1];
[transDerecha setStartProgress:0];
[transDerecha setType:kCATransitionMoveIn];
[transDerecha setSubtype:kCATransitionFromLeft];
[transDerecha setDelegate:self];
Ok, but to get the aspect that i am looking for, i have created a UIView (blue one on the video).
I think that in the following video, you can see better what i am trying to say.
http://screencast.com/t/JMQmxe7CGy
The problem comes when i try to make the same thing on the left. If i create another UIView to cover the left UIView, it will cover also the right cover.
So, is there any other CATransition type to make that? Or any solution?
ThankS!!!
I dont think you need to dive down to CA to do this kind of thing. It can be done using UIView animations. Here http://www.raywenderlich.com/2454/how-to-use-uiview-animation-tutorial is a good tutorial on UIView animations.
Related
Writing up an code for creating table view in such a manner when user scroll table view it behaves like cube. Please find below youtube link for the vision what I am asking for:
http://www.youtube.com/watch?v=hrBxHq83yKQ
Meanwhile, I tried with CATransform3D transform = CATransform3DMakeRotation(angle, 1, 0, 0); and it working for adding up an row at the top but not for scrolling.
Further, due to lack of knowledge of OpenGLES I can not go with it for rotating the cubes with touch gesture. Please suggest for the same as per your feasibility.
Look forward to hear from you.
check it out.. hope it helps you..
Link 1: https://www.cocoacontrols.com/controls/abcustomuinavigationcontroller
Link 2: https://github.com/augustjoki/CubeTabBarController
you can achieve this effects with Layer transform and a scrollview. To build a cube take a look at this post. You might add some overlays to your cube-sides to simulate lightning and you are done.
I got an answer for cubical scrolling. Earlier I was using below source code link:
GestureBasedTableViewDemo
Meanwhile, above tableview demo was using gesture and allow me to only add first row in tableview cell while scrolling down but my requirement was to have cubical scrolling up or down both.
Further, I tried with vertical iCarousel cylindrical and I achieved the vertical cubical scrolling. Thanks
You might also want to check our implementation of a gesture based 3D-cube over at Chubamobile:
http://www.chupamobile.com/products/details/2106/Cube+Selector/
It's fully featured, ready to use out of the box - and pretty much exactly what you want
Maybe it helps.
CATransition *animation = [CATransition animation];
animation.duration = 1;
animation.type = #"cube";
animation.subtype = #"fromRight";
[self.contentView.layer addAnimation:animation forKey:#"animation"];
[self.contentView bringSubviewToFront:view];
or that link http://www.albertopasca.it/whiletrue/objectivec-3d-view-rotation/
Don't dislike - there are few information about it.
I'm new to iOS. I've read lot of tutorial and I see that all most of example using NavigationController in multiple view. We always force to use NavigationController?
If I have a single view, on my view I have a button1, and when I click on that button it's will open a new view. I also have another button2, when I click on button2, a dialog display on original view. So in this case, I still have to use NavigationController? Another controller I can use?
Thanks in advance!
Navigation controller is not an only option... If u made the flow of your app in such a way that it requires navigation,then only u should use navigation controller.. otherwise there is an another option like presentModalViewController,and u can also use hide/show view while showing dialog in your original view. If you can elaborate your question ,then i might help you.
It's mainly for aesthetic reasons and continuity of user experience that you use navigation controller. You of course can use buttons, but navigation controller is more like the standard for multiple views.
It is not necessary to use the Navigation controller..You can give similar kind of side transition(LEFT to Right or right to left) using Quartz-core animation effect.
Home *homeObject=[[Home alloc] init];
CATransition *animation = [CATransition animation];
[self presentModalViewController:homeObject animated:NO];
[animation setDuration:0.40];
[animation setType:kCATransitionPush];
[animation setSubtype:kCATransitionFromLeft];
[[homeObject.view layer] addAnimation:animation forKey:#"SwitchToView1"];
[homeObject release];
I want to create an 'unfold' animation to a UIView that appears on the screen.
An example of the animation can be viewed in this YouTube video that reviews the SuperList app (Another example of the animation can be viewed in the app's App Store page in the screenshots section).
I have quite good understanding of Core Animation and Objective C, so as with Cocoa and Cocoa Touch. The app will support versions 5.x and 4.x of iOS so, if it is possible, I would prefer a solution that suits both cases.
Moreover, I have googled this question about a thousand times and failed to get any answers, so help will be much appreciated. Thanks ahead, iLyrical.
Apparently, the 'UnCurl' effect is built-in with the framework and is your to use!
All you have to do, is use the animateWithDuration: animation: method of the UIView class and include the animation as follows:
[UIView animateWithDuration:1.0
animations:^{
CATransition *transition = [CATransition animation];
[transition setDelegate:self];
[transition setDuration:0.7];
[transition setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn]];
[transition setType:#"pageUnCurl"];
[self.view.layer addAnimation:transition forKey:#"pageUnCurl"];
[self.view addSubview:someView.view];
}];
The note image (white page) in this case has transparent section (all side) and thus when uncurl happens it looks like only the white part is uncurling.
I have seen lots of people asking on how to push/pop UINavigationControllers using other animations besides the default one, like flip or curl.
The problem is that either the question/answer was relative old, which means the have some things like [UIView beginAnimations:] (example here) or they use two very different approaches.
The first is to use UIView's transitionFromView:toView:duration:options:completion: selector before pushing the controller (with the animation flag set to NO), like the following:
UIViewController *ctrl = [[UIViewController alloc] init];
[UIView transitionFromView:self.view
toView:ctrl.view
duration:1
options:UIViewAnimationOptionTransitionFlipFromTop
completion:nil];
[self.navigationController pushViewController:ctrl animated:NO];
Another one is to use CoreAnimation explicitly with a CATransaction like the following:
// remember you will have to have the QuartzCore framework added to your project for this approach and also add <QuartzCore/QuartzCore.h> to the class this code is used
CATransition* transition = [CATransition animation];
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn];
transition.duration = 1.0f;
transition.type = #"flip";
transition.subtype = #"fromTop";
[self.navigationController.view.layer removeAllAnimations];
[self.navigationController.view.layer addAnimation:transition forKey:kCATransition];
UIViewController *ctrl = [[UIViewController alloc] init];
[self.navigationController pushViewController:ctrl animated:NO];
There are pros and cons for both approaches.
The first approach gives me a much cleaner code but restricts me from using animations like "suckEffect", "cube" and others.
The second approach feels wrong just by looking at it. It starts by using undocumented transitions types (i.e. not present in the Common transition types documentation from CATransition Class Reference) which might get your app rejected from App Store (I mean might as I could not found any reference of apps being rejected because it was using this transactions, which I would also appreciate any clarification on this matter), but it gives you much more flexibility on your animations, as I can use other animation types such as "cameraIris", "rippleEffect" and so on.
Regarding all that, do I really need to appeal for QuartzCore and CoreAnimation whenever I need a fancier UINavigationController transition? Is there any other way to accomplish the same effect using only UIKit?
If not, will the use of string values like "flip" and "cube" instead of the pre-defined constants (kCATransitionFade, kCATransitionMoveIn, etc...) be an issue regarding my app approval in the App Store?
Also, are there other pros and cons regarding both approaches that could help me deciding whether to choose each one of them?
With regards to the AppStore approval, I don't think its a deal-breaker based on what animation libraries you use. You can use which ever you feel is convenient for you, and can use them together as well. From a personal standpoint, I would say the CoreAnimation & QuartzCore are pretty awesome when you are trying to add animation to a particular event. Its great because of the level of detail you can add to individual components.
But those are not your only options. You should have a look at COCOS2D libraries for animation. They are really awesome and extremely simple to use. For example if using CoreAnimation takes you 30 lines of code, you can use COCOS2D and set it up with 3-5 lines of code. Also, you can integrate Physics with each component when you use the COCOS2D framework (chipmunk).
In my iPhone app, I have put a UIBarBUtton of type UIBarButtonSystemItemTrash in my UIToolBar. When pressed, I'd like to replicate the animation of Mail.app: the bin opens, the UIView folds and flies into it.
Is there a way to access this animation ithrough the iPhone SDK?
Presently I am using a custom made animation, but there are some limits; for example, I cannot animate the bin itself.
Do you have any suggestion? Code samples?
Cheers,
Davide
Use the suckEffect type on an animation. Also: spewEffect, genieEffect, unGenieEffect, twist, tubey, swirl, cameraIris, cameraIrisHollowClose, cameraIrisHollowOpen, rippleEffect, charminUltra, zoomyIn, and zoomyOut. Doesn't work in the simulator.
CATransition *animation = [CATransition animation];
animation.type = #"suckEffect";
animation.duration = 2.0f;
animation.timingFunction = UIViewAnimationCurveEaseInOut;
view.opacity = 1.0f;
[view.layer addAnimation:animation forKey:#"transitionViewAnimation"];
Note: Code snippet was pulled from a larger codebase. I hope it works :)
Just to add some info:
You can use "suckEffect" with the standard +[UIView setAnimationTransition:forView:cache:]. Just pass the number 103 to the animationTransition variable. This won't avoid your app being rejected by Apple though :p
"spewEffect", "genieEffect", "unGenieEffect", etc. no longer exist on iPhoneOS 3.x. The only undocumented transition left are "cube" (--), "rippleEffect" (110), the three "cameraIris" effects (105,106,107) and "suckEffect" (103).
See http://www.iphonedevwiki.net/index.php?title=UIViewAnimationState for detail.
Also, to animate the bin (with private API): http://www.iphonedevwiki.net/index.php?title=UIToolbar#Animating_the_trash_can_icon.
Unfortunately, I think this is going to need to be an entirely custom animation. The UIView folding can be approximated using Core Animation, perhaps by adding perspective to the CATransform3D of the UIView's underlying layer to distort the UIView into a trapezoid which gets sucked into the trash can.
As far as the trash can, you can create a UIBarButtonItem using initWithCustomView:, which might let you insert a custom UIView that has an animatable trashcan. It looks like the trash can has two elements, the can base and the lid, which are rotated independently to open and close the can. Draw PNGs for both, make UIImageViews for them, and make them subviews of the UIBarButtonItem custom view. For opening and closing, apply rotational transforms to them to animate the subviews.
I'm not sure if this is an answer but here is lib that do "genie effect" so it's quite similar to what you want achieve.
CGRect endRect = CGRectMake(30, 40, 50, 60);
[view genieInTransitionWithDuration:0.7
destinationRect:endRect
destinationEdge:BCRectEdgeTop
completion:^{
NSLog(#"I'm done!");
}];