core-animation

Static background for CGContext

青春壹個敷衍的年華 提交于 2019-12-05 17:30:40
this is my first question here, so hello everyone. I have spent some time now wrapping my mind around the following problem and could not come up with a solution. I'd be happy if someone could point me in the right direction. I'm using CGContext to draw various layers of graphical representations of live data which should be refreshed at a reasonable framerate of at least 50fps. I want to use a static image as a background. Re-drawing this image using the context for every cycle significantly slows down the frame-rate. I thought about just using UIImageView to display the image once. The

How to interact with layer-backed views on the Mac

扶醉桌前 提交于 2019-12-05 16:54:59
I am designing a user interface containing several labels and text fields. I would like to style the UI like this: setting a background pattern for the content view of my NSWindow adding a custom icon to the background in the upper left corner I solved the first problem by making the content view a layer-backed view as described in Apple's documentation of NSView : A layer-backed view is a view that is backed by a Core Animation layer. Any drawing done by the view is the cached in the backing layer. You configured a layer-backed view by simply invoking setWantsLayer: with a value of YES . The

What is the role of key path in Core Animation?

被刻印的时光 ゝ 提交于 2019-12-05 15:17:00
I'm getting acquanted with Core Animation and trying to implement simple movement along a curve line. i've found really helpful piece of code here There is a line there: CAKeyframeAnimation *pathAnimation = [CAKeyframeAnimation animationWithKeyPath:@"position"]; Why do we need this property named keyPath? What is its role? The code works only if use the proposed NSString @"position" and nothing else. So is it a built-in constant string? It doesn't look so. Hope you see my confusion. Can you please explain in plain language how do i manage this keyPath property? KeyPath says which animatable

CAShapeLayer path disappears after animation - need it to stay in the same place

拈花ヽ惹草 提交于 2019-12-05 14:11:54
Thanks to some help on StackOverflow, I am currently animating a path in CAShapeLayer to make a triangle that points from a moving sprite to another moving point on the screen. Once the animation completes, the triangle disappears from the screen. I am using very short durations because this code is being fired every .1 of second for each of the sprites. The result is the red triangle tracks correctly, but it rapidly flashes or isn't there entirely. When I crank up the the duration, I can the see the triangle stay longer. What can I do to get the triangle to stay on the screen, with it's

When is it appropriate to use Core Animation over UIView animation in common cases

此生再无相见时 提交于 2019-12-05 13:53:27
This is related to a lot of little bugs that might stereotypically be considered minor by one person, but major by another. What I've noticed more and more, is that when using all flavors a UIView animateWithDuration: , it actually modifies things unnecessarily, such multiple properties of my views', to do a simple hide/reveal style animations, etc.. Things seem to be finicky in scenarios like a UINavigationBar not animating into position properly for a certain rotation transition, or a header view not animating along with the status bar when it's frame updates, when when a view's sublayers

Add a shadow to CAShapeLayer, so that the inside remains transparent

孤人 提交于 2019-12-05 12:02:39
I want to add a glow effect to a path, like the blue glow around (OS X) interface elements when they have focus. I used a CAShapeLayer with a (rectangular) path: self.borderLayer = [CAShapeLayer layer]; CGPathRef path = CGPathCreateWithRect(self.bounds, NULL); [self.borderLayer setPath:path]; CGPathRelease(path); In the end this gives me a transparent UIView with a border around it. (In my concrete case it's a dashed line with an additional animation, but that doesn't matter for this particular question) I played around with the shadow properties of CALayer, but they will always fill the whole

How come my Core Animation transformation always returns to it's start-state?

让人想犯罪 __ 提交于 2019-12-05 11:32:55
I am trying to perform some kind of animation of a layer in my iPhone application. It does not matter what I do I always get the same results: after the animation is done it jerks back into it's original position. Even though I set removedOnCompletion to false there is no difference. What am I missing here? Thanks in advance! EDIT: Really need help with this one guys. I am creating animations with CAKeyframeAnimation and CABasicAnimation objects, then adding them to a CAAnimationGroup which I in turn att to the layer. The animation works as predicted except that it always snaps back to it's

Core Animation and Anti Aliased Fonts on the Mac

天涯浪子 提交于 2019-12-05 10:17:36
I'm trying to create a view that is backed by a Core Animation layer. However, when I enable the layer, my labels start to look slightly jagged. I've attached a demonstration of difference: I know it is subtle, but it is driving me crazy (especially for smaller fonts). Any way I can get the Core Animation layer labels to be anti-aliased? Nitpick: the Core Animation layer is anti-aliased, but at a lower quality – it doesn’t use sub-pixel anti-aliasing. The reason for this is that sub-pixel anti-aliasing requires per-channel blending, which can’t be done cheaply with hardware compositing. The

Moving an image along a series of CGPoints

本秂侑毒 提交于 2019-12-05 10:04:47
I have path stored in an array of CGPoints which I'd like to move an image along. Here's the general code I have so far: -(void)movePic:(id)sender{ for(int i = 0; i < self.array.count; i++){ CGPoint location = [[self.array objectAtIndex:i] CGPointValue]; [UIView animateWithDuration:0.1 animations:^{ self.imageView.center = location; } completion:^(BOOL finished){ }]; } } The problem is the for loop runs extremely fast, so you only see the animation on the last points. I'm unsure of how to better design this. Ideally, what could I do to make sure one animation finishes before the other begins?

multiple CAKeyframeAnimation in different layers at the same time

老子叫甜甜 提交于 2019-12-05 09:32:13
Does anyone now how can I animate multiple layers at the same time using CAKeyframeAnimation ? Each layer has its own CAKeyframeAnimation object. Take a look at the code below: I have a method that receives an object, creates the CAKeyframeAnimation and attaches the animation to it: - (void)animateMovingObject:(CALayer*)obj fromPosition:(CGPoint)startPosition toPosition:(CGPoint)endPosition duration:(NSTimeInterval)duration { CAKeyframeAnimation *pathAnimation = [CAKeyframeAnimation animationWithKeyPath:@"position"]; pathAnimation.calculationMode = kCAAnimationPaced; //pathAnimation.fillMode =