UIView animation VS core animation
I’m trying to animate a view sliding into view and bouncing once it hits the side of the screen.
A basic example of the slide I’m doing is as follows:
// The view is added with a rect making it off screen. [UIView beginAnimations:nil context:NULL]; [UIView setAnimationBeginsFromCurrentState:YES]; [UIView setAnimationDuration:0.07]; [UIView setAnimationCurve:UIViewAnimationCurveLinear]; [UIView setAnimationDelegate:self]; [UIView setAnimationDidStopSelector:@selector(animationDidStop:finished:context:)]; [theView setFrame:CGRectMake(-5, 0, theView.frame.size.width, theView.frame.size.height)]; [UIView commitAnimations];
More animations are then called in the didStopSelector to make the bounce effect. The problem is when more than one view is being animated, the bounce becomes jerky and, well, doesn’t bounce anymore.
Before I start reading up on how to do this in Core Animation, (I understand it’s a little more difficult) I’d like to know if there is actually an advantage using Core Animation rather than UIView animations. If not, is there something I can do to improve performance?
Solutions Collect From Internet About “UIView animation VS core animation”
With Core Animation (Layer based) you can do much advanced things, like 3d animation (embedding your view in 3d space).
UiView animations are quite powerful though, and shouldn’t be a performance bottleneck until you have plenty of them. I only see one example in your code, and its duration is extremely short. In fact, you are almost setting the frame property instantly (70 ms is 14 fps). You should think of UIView animation in terms of start, end, and the duration for the whole distance – which is typically 0.2 s to several seconds. It is not designed to to fire one micro animation after another.
- Xcode adding new files to existing project in svn
- Error when trying to save image in NSUserDefaults using Swift
- animateWithDuration not working inside GMSMapView delegate method
- UITableView with fixed image background
- UIColor comparison
- How to convert an NSArray of NSManagedObjects to NSData
- Xcode 8 Swift 3: Modal presentation transitioning delegate not called
- Can I set the cookies to be used by a WKWebView?
- How to get data from UIDatePicker – Swift
- UIBarButtonItem: How can I find its frame?
- Landscape xib appears as portrait
- ObjectMapper how to map different object based on JSON
- How to save an array to a Realm Object
- How to use a xib and a UIView subclass together?
- iOS Push notifications not working on for ad hoc distributions with Test Flight