core-animation

How to make my UIBezierPath animated with CAShapeLayer?

一个人想着一个人 提交于 2019-12-17 10:46:41
问题 I'm trying to animate a UIBezierPath and I've installed a CAShapeLayer to try to do it. Unfortunately the animation isn't working and I'm not sure any of the layers are having any affect (as the code is doing the same thing it was doing before I had the layers). Here is the actual code - would love any help. Draw2D is an implementation of UIView that is embedded in a UIViewController. All the drawing is happening inside the Draw2D class. The call to [_helper createDrawing... ] simply

When exactly do implicit animations take place in iOS?

柔情痞子 提交于 2019-12-17 10:35:09
问题 Everyone and every book claims that there are implicit animations happening in CALayer. However, every time I wanted to verify that so far, I end up with a hard-snap to the set value. No animation at all. Here's an example in a project where nothing else is happening. All I do is create a view, then get it's CALayer instance and do something that should be implicitly animated. [theLayer setValue:[NSNumber numberWithFloat:M_PI * 1.1] forKeyPath:@"transform.rotation.z"]; Another one: CGRect

Best Way to Perform Several Sequential UIView Animations?

可紊 提交于 2019-12-17 10:34:07
问题 I have a series of 8 UIView animations that occur directly after my view is loaded. Right now, I am accomplishing this by using the animationDidStop:finished:context delegate method, and everything works as expected. The problem is that I have a new method for each animation. Most of the code in each of these methods is repeated, with only the animation duration and the actual positioning of elements changing. I tried to create a single method which would be called and have the context hold

Using CABasicAnimation to rotate a UIImageView more than once

烂漫一生 提交于 2019-12-17 10:29:22
问题 I am using a CABasicAnimation to rotate a UIImageView 90 degrees clockwise, but I need to have it rotate a further 90 degrees later on from its position after the initial 90 degree rotation. CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"]; animation.duration = 10; animation.additive = YES; animation.removedOnCompletion = NO; animation.fillMode = kCAFillModeForwards; animation.fromValue = [NSNumber numberWithFloat:DEGREES_TO_RADIANS(0)]; animation

UIView vertical flip animation

你离开我真会死。 提交于 2019-12-17 08:00:21
问题 I have an iOS UIView with UIViewAnimationTransitionFlipFromRight . I need it to flip vertically though. The page curl transition won't cut it. I assume this will require something custom. Any ideas? 回答1: As of iOS 5.0, there's no need to write your own Core Animation transformation to do vertical flips. Just use UIKit's UIViewAnimationOptionTransitionFlipFromTop and UIViewAnimationOptionTransitionFlipFromBottom transitions, and all this stuff becomes a single method call. These behave

Animation End Callback for CALayer?

允我心安 提交于 2019-12-17 07:12:52
问题 I'm wondering where the callbacks are (or if there are anything) for animations in a CALayer. Specifically, for implied animations like altering the frame, position, etc. In a UIView, you could do something like this: [UIView beginAnimations:@"SlideOut" context:nil]; [UIView setAnimationDuration:.3]; [UIView setAnimationDelegate:self]; [UIView setAnimationDidStopSelector:@selector(animateOut:finished:context:)]; CGRect frame = self.frame; frame.origin.y = 480; self.frame = frame; [UIView

What are block-based animation methods in iPhone OS 4.0?

点点圈 提交于 2019-12-17 04:16:48
问题 I am trying to implement a game using the iPhone OS 4.0 (iOS4?) SDK. In the previous versions of the SDK, I've been using the [UIView beginAnimations:context:] and [UIView commitAnimations] to create some animations. However, when I look at the documentation of the functions in 4.0, I see this comment. Use of this method is discouraged in iPhone OS 4.0 and later. You should use the block-based animation methods instead. You can find it here: http://developer.apple.com/iphone/library

Can I use CGAffineTransformMakeRotation to rotate a view more than 360 degrees?

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-17 03:56:12
问题 I'm writing an iPhone app, and I've got an image which I'ld like to have swirl outwards. Currently my code looks like this (wrapped in a beginAnimations/commitAnimations block): scale = CGAffineTransformScale(CGAffineTransformIdentity, 5.0f, 5.0f); swirl = CGAffineTransformRotate(scale, M_PI); [player setTransform:swirl]; [player setAlpha:0.0f]; But I find that if I try to change the angle of the rotation to, say, 4*M_PI, it doesn't rotate at all. Is it possible to get a 720˚ rotation using

Objective-C - CABasicAnimation applying changes after animation?

拥有回忆 提交于 2019-12-17 02:55:20
问题 I am using CABasicAnimation to move and resize an image view. I want the image view to be added to the superview, animate, and then be removed from the superview. In order to achieve that I am listening for delegate call of my CAAnimationGroup , and as soon as it gets called I remove the image view from the superview. The problem is that sometimes the image blinks in the initial location before being removed from the superview. What's the best way to avoid this behavior? CAAnimationGroup

Draw segments from a circle or donut

*爱你&永不变心* 提交于 2019-12-17 02:53:05
问题 I've been trying to figure out a way to draw segments as illustrated in the following image: I'd like to: draw the segment include gradients include shadows animate the drawing from 0 to n angle I've been attempting to do this with CGContextAddArc and similar calls but not getting very far. Can anyone help ? 回答1: There are many parts to your question. Getting the path Creating the path for such a segment shouldn't be too hard. There are two arcs and two straight lines. I've previously