core-animation

Stop and start an animation by touch. Objective C

混江龙づ霸主 提交于 2019-12-06 00:13:02
问题 I have made an animation that moves across the screen, my animation loops continuously. How can I stop the animation when you tap the animated image, Then let the animation continue when you lift the touch? I know how to use TouchesMoved to move a specified button like this: CGPoint point = [[[event allTouches] anyObject] locationInView:self.view]; UIControl *control = sender; control.center = point; But getting it to work with my animation. I would like the animation to continue after I

CALayer vs. drawInRect: performance?

别来无恙 提交于 2019-12-06 00:05:48
I'm trying to draw some shadows in a rect. The shadow image itself is about 1px * 26px. Here's two methods I've thought of for drawing the image in the view: //These methods are called in drawRect: /* Method 1 */ [self.upperShadow drawInRect:rectHigh]; //upperShadow is UIImage [self.lowerShadow drawInRect:rectLow]; /* Method 2 */ CALayer *shadowTop = [CALayer layer]; shadowTop.frame = rectHigh; shadowTop.contents = (__bridge id)topShadow; //topShadow is CGImage [self.layer addSublayer:shadowTop]; CALayer *shadowLow = [CALayer layer]; shadowLow.frame = rectLow; shadowLow.contents = (__bridge id

Pausing a SceneKit animation

时光总嘲笑我的痴心妄想 提交于 2019-12-05 23:08:31
I'm trying to create a test app in which the user can pause an animation by clicking in the SceneView. The SceneView loads the animation from a .dae file created in a 3d app (Cinema 4D). The app successfully plays and loops the animation upon launch. To pause the animation, I used Technical Q&A QA1673 as a reference. In the case of this .dae file, the animation actually comes in as a hierarchy of animations, so I have tried reaching down to each underlying CAKeyframeAnimation and setting its speed to zero. My code currently looks like this: - (void)mouseDown:(NSEvent *)event { SCNNode

CALayer not displaying

旧街凉风 提交于 2019-12-05 22:57:03
So this is my first ever attempt at using a CALayer. Build is successful and no reported bugs, so I assume I must be doing something obviously wrong. But the layer does not display at all. - (void)viewDidLoad { // Get Reliant Magenta in amazingly verbose manner CGColorSpaceRef rgbaColorSpace = CGColorSpaceCreateDeviceRGB(); CGFloat reliantMagentaValues[4] = {(208/255),(27/255),(124/255),0.3f}; CGColorRef reliantMagenta = CGColorCreate(rgbaColorSpace, reliantMagentaValues); CALayer *reliantCanvasLayer = [CALayer layer]; reliantCanvasLayer.backgroundColor = reliantMagenta; reliantCanvasLayer

How would I make an explosion animation on iOS?

萝らか妹 提交于 2019-12-05 22:39:17
I have an iOS game, and when a ball hits a target it explodes. What would be the best way to animate this explosion? If you're looking for something simple. Make a series of images that animate the explosion. Add those to a UIImageView and start the animation. Something like this: UIImage *image0 = [UIImage imageNamed:@"explosion0.png"]; UIImage *image1 = [UIImage imageNamed:@"explosion1.png"]; UIImage *image2 = [UIImage imageNamed:@"explosion2.png"]; UIImage *image3 = [UIImage imageNamed:@"explosion3.png"]; myImageView.animationImages = [NSArray arrayWithObjects:image0, image1, image2, image3

CATextLayer subpixel antialiasing

限于喜欢 提交于 2019-12-05 21:57:21
My app draws layer-backed labels over a NSImageView . The image view displays an image, and a tint color over that image. This ensures that the contrast between the labels and the background image works. As you can see, subpixel antialiasing is enabled and works correctly. When you hover over those labels, they animate the frame property (Actually the view containing them). While animating, the subpixel antialiasing is disabled, and when done enabled again. This looks incredibly weird. The layer is never redrawn, and the subpixel antialiasing doesn't have to change. So I don't see a good

how to know when a coreanimation animation ends

泪湿孤枕 提交于 2019-12-05 21:42:54
I'm doing some animations with core animation, but I can't found a way to know with a notification or event when the animation block has finish, like in UIVIew animation block you have setAnimationDidStopSelector: how can I know this in core animation, thanks for any help If you are using a CAAnimation instance, look at the animationDidStop:finished: for its delegate. CAAnimation * animation = [CAAnimation animation]; animation.delegate = yourDelegate; // could be self, for example. [yourLayer setAnimation:animation forKey:nil]; In the example above, yourDelegate should implement the

SceneKit Rigged Character Animation increase performance

落爺英雄遲暮 提交于 2019-12-05 19:42:09
I have *.DAE files for characters each has 45-70 bones, I want to have about 100 animated characters on the screen. However when I have ~60 Characters the animations takes ~13ms of my update loop which is very costly, and leaves me almost no room for other tasks. I am setting the animations "CAAnimationGroup" to the Mesh SCNNode when I want to swap animations I am removing the previous animations with fadeOut set to 0.2 and adding the new Animation with FadeIn set to 0.2 as well. -> Is it bad ? Should I just pause a previous animation and play a new one ? or is it even worse? Is there better

How can I use core animation to animate the background color of an NSTextField?

ε祈祈猫儿з 提交于 2019-12-05 19:19:23
问题 I'm trying to use core animation to highlight a text field as being invalid. [[my_field animator] setBackgroundColor [NSColor yellowColor]] Updates the field background color, but does not animate the change. Updating properties such as the position of the field animates properly. I'm assuming this is because background color isn't included in the NSAnimatablePropertyContainer search. I've also tried creating the animation explicitly, to no avail. CABasicAnimation *ani; ani =

Layer-backed NSView animation

旧街凉风 提交于 2019-12-05 17:54:49
I have a certain NSView that I want to animate, but that NSView has a NSTableView inside which does not display correclty when the view is layer-backed (which in turn is nececessary to animate a view). So my answer was to make the view layer-backed right before animating, and then when the animation was done remove the layer, like this: [animatingView setWantsLayer: YES]; [NSAnimationContext beginGrouping]; [[animatingView animator] animateSomething]; [[NSAnimationContext currentContext] setCompletionHandler: ^{ [animatingView setWantsLayer: NO]; }]; [NSAnimationContext endGrouping]; However,