core-animation

iphone: Restart looping animation after view is hidden, then reappears?

陌路散爱 提交于 2019-12-10 15:29:10
问题 My app has a tab bar with two different views. On the first tab, its view has a continuously-looping animation. When I click on the second tab, then go back to the first, the animation has stopped. I know I could start it again in a viewWillAppear: method, but the problem is bigger than that. Specifically, the animation will also stop if the app transitions to the background state, then moves back to the foreground. In that case, viewWillAppear is not called upon the foreground transition, so

How to group two CABasicAnimation animations and kick them off at the exact same time?

六眼飞鱼酱① 提交于 2019-12-10 15:29:05
问题 I know there is some kind of animation grouping mechanism in core animation. So lets say I have two CABasicAnimation firstAnimation and secondAnimation . How would I group these and how would I kick off the group to start animating? 回答1: You'll want to use the CAAnimationGroup class. Create an array containing the animations you want, and set the AnimationGroup's animations property to that array. CAAnimationGroup is a subclass of CAAnimation, so you can add it to a layer using [layer

How to scale and rotate a view in a single animation

泪湿孤枕 提交于 2019-12-10 15:15:51
问题 I am trying to present a view by making it emerge from the centre of the screen while growing to its full size, while also rotating it around the x-axis in a 3D manner. When I create the view I apply a transform to it to make sure it is shrunk and rotated to start off with (it is so small it is not actually visible), then I try to use a CATransform3D like this: CABasicAnimation *anim = [CABasicAnimation animationWithKeyPath:@"transform"]; CATransform3D transform = CATransform3DRotate(view

Animation End Callback for CALayer?

空扰寡人 提交于 2019-12-10 14:49:01
问题 Using iPhone CALayer, I want a rotation animation for my spirit layer, but I also want a callback for the animation end, hot to do that? I think maybe I should use CABasicAnimation, but I don't know how to do rotation using CABasicAnimation, any idea? Thanks 回答1: If you set a delegate for a CAAnimation, you can add the callback method: - (void)animationDidStop:(CAAnimation *)theAnimation finished:(BOOL)flag That gets called when the animation is complete. Look for examples of rotating

Possible to copy CALayer from UIView?

别来无恙 提交于 2019-12-10 14:02:27
问题 Here's my setup: I have a CALAyer to which I want to add sublayers. I create these sublayers by setting upa UILabel and then adding the UILables layer to my main layer. Of course this leaves the heavy UILabel object hovering around in the background. Is it possible to get the layer with all its content from a UIView and get rid of the UIView itself? I already tried this: UILabel* label; [...] [mainLayer addSublayer:[label.layer copy]]; [label release]; But whenever I release the UIView, the

When should we use CATransformLayer?

扶醉桌前 提交于 2019-12-10 13:10:07
问题 I have read the documentation and several examples, but still cannot understand when exactly to use a CATransformLayer . A normal CALayer flattens everything at the z = 0 plane, but isn't that what a CATransformLayer does too? A mathematical explanation would be very helpful. 回答1: To fully understand what are the differences between CALayer and CATransformLayer, you should read this article It is the best tutorial which explains how to use CATransformLayer . But to say briefly, Consider a

Multiple CALayers Animation - Fill Mode

柔情痞子 提交于 2019-12-10 13:09:36
问题 I am separating the screen into small tiles, then animating each tile to perform a transition: for (int x=0; x<number_of_x_splits; x++) { for (int y=0; y<number_of_y_splits; y++) { CGSize splitSize = CGSizeMake(screenBounds.width / number_of_x_splits, screenBounds.height / number_of_y_splits); CATransformLayer *transformLayer = [CATransformLayer layer]; [transformLayer setFrame:CGRectMake(splitSize.width * x, splitSize.height * y, splitSize.width, splitSize.height)]; [transformLayer

Is Core Animation color blended layers useful or say is it necessary?

元气小坏坏 提交于 2019-12-10 13:03:32
问题 Color Blended Layers Open Instruments and choose the Core Animation template located under iOS / Graphics. First, click in the Core Animation instrument's timeline to reveal the bottom pane and find the section labeled "Debug Options". Check the "Color Blended Layers" box, which will show a red overlay over layers that were blended and a green overlay over layers drawn without blending. Is Core Animation color blended layers useful or say is it necessary? I found that the system UI is red

How to make rounded corners and sides in UIview programmatically?

那年仲夏 提交于 2019-12-10 12:32:56
问题 How to make rounded corners and sides in UIview programmatically like has youtube: I know how to make rounded corner but have no idea how to make rounded sides. I need to do it programmatically (not just setting image mask previously designed) 回答1: You can create a UIBezierPath . If you want to just round the corners, you can use bezierPathWithRoundedRect . If you want something more sophisticated, like that YouTube logo, you would use moveToPoint and a series of addCurveToPoint or

iPhone CALayer animation

倖福魔咒の 提交于 2019-12-10 11:58:25
问题 I am drawing a line animation, connecting 2 points with a line. This is my code: -(void) drawObject{ rootLayer = [CALayer layer]; rootLayer.frame = self.view.bounds; [self.view.layer addSublayer:rootLayer]; lineStartPath = CGPathCreateMutable(); CGPathMoveToPoint(lineStartPath, nil, 160, 50); CGPathAddLineToPoint(lineStartPath, nil, 160, 50); CGPathCloseSubpath(lineStartPath); lineEndPath = CGPathCreateMutable(); CGPathMoveToPoint(lineEndPath, nil, 160, 50); CGPathAddLineToPoint(lineEndPath,