core-animation

How to synchronize OpenGL drawing with UIKit updates

牧云@^-^@ 提交于 2019-12-03 18:32:41
问题 In our app we have UIScrollView above CAEAGLLayer. UIScrollView contains some UIViews (red rectangles). In CAEAGLLayer we draw white rectangles. Centers of white rectangles are the same as the centers of red rectangles. When UIScrollView scrolls, we update positions of white rectangles in CAEAGLLayer and render them. We are getting the expected result: centers of white rectangles are always the same as centers of red rectangles. But we can't synchronize updates of the CAEAGLLayer with the

CAShapeLayer animation (arc from 0 to final size)

萝らか妹 提交于 2019-12-03 17:43:19
问题 I have a CAShapeLayer in which an arc is added using UIBezierPath . I saw a couple of posts (one actually) here on stackoverflow but none seemed to give me the answer. As said in the title I would like to animate an arc (yes it will be for a pie chart). How can one accomplish an animation from an "empty" arc to the fully extended one? Kinda like a curved progress bar. Is it really impossible to do it via CoreAnimation ? Here's how I "do" the arc. Oh and ignore the comments and calculation

Properties on CALayer subclass aren't getting observed by CATransaction

谁说胖子不能爱 提交于 2019-12-03 17:18:36
I have a subclass of CALayer with a custom property, declared as such: @interface MyLayer : CALayer @property (nonatomic,retain) NSNumber *customValue; @end @implementation MyLayer @synthesize customValue = _customValue; @end I want to animate this property inside of an explicit CATranasction , so i set up a delegate with the actionForLayer:forKey: method implemented which returns an animation, however any changes to someMyLayerInstance.customValue inside of [CATransaction begin] ... [CATransaction end] do not result in actionForLayer:forKey getting called with a corresponding 'key' value.

How to render a CALayer with a different blending mode, like screen or multiply?

亡梦爱人 提交于 2019-12-03 17:18:18
问题 I have a UIImageView and want it to be displayed with a specific blend mode. I know the iPhone has different blend modes, and it's probably possible to do it with a lot of CG code… but maybe there's a nice way with the CALayer of UIImageView ? 回答1: see here: composite colors: CALayer and blend mode on iPhone 回答2: Set the compositingFilter of a view's layer to a supported blend mode string. From the docs, a layer's compositingFilter is A CoreImage filter used to composite the layer and the

Masking a CALayer with another CALayer

痞子三分冷 提交于 2019-12-03 17:13:26
问题 I'm trying to make a donut shape with CALayers. One CALayer will be a large circle, the other one will be a smaller circle positioned in its center, masking it. The large circle displays fine, but whenever I call circle.mask = circleMask; then the view appears empty. Here's my code: AriDonut.h #import <UIKit/UIKit.h> @interface AriDonut : UIView -(id)initWithRadius:(float)radius; @end AriDonut.m #import "AriDonut.h" #import <QuartzCore/QuartzCore.h> @implementation AriDonut -(id

what is byte alignment (cache line alignment) for Core Animation? Why it matters?

拈花ヽ惹草 提交于 2019-12-03 16:40:59
I am loading images on a scroll view in a non-lazy way, so that the stutter behavior is not seen. The code works and the FPS is close to 60. BUT, I do not understand what is byte alignment (or cache line alignment) for Core Animation? As mentioned here and here this is an important thing to do. However, I noticed as long as I do the steps mentioned here , byte-alignment or not does not really matter. Anyone knows what exactly it is? When the CPU copies something from memory into the CPU cache it does so in chunks. Those chunks are cache lines and they are of a fixed size. When data is stored

CABasicAnimation and custom types

安稳与你 提交于 2019-12-03 16:12:55
I'm not very familiar with CoreAnimation, so I hope I've just missed something pretty simple. I want to animate a custom property ( NSGradient ) of a NSView in a simple manner, with [[view animator] setGradient:gradient]; . I defined + (id)defaultAnimationForKey:(NSString *)key and returned a simple CABasicAnimation, however, no animation is executed. Since this works for simpler types and NSColor, I guess CABasicAnimation doesn't work with gradients. Fine, but in this particular case gradients are trivial (two stops, always), so I can easily write an interpolation functions. The question :

What is different between CoreGraphics and CoreAnimation?

耗尽温柔 提交于 2019-12-03 16:05:12
I am developing iphone game using coregraphics. but the speed is very slow. I could not play my game.. So, I googled a lot.. During the googling, I found the belows. CoreGraphics, CoreAnimation, OpenGL ES, CALayer, Quartz 2D I am so confused between them. Someone told me coregraphics is not using GPU. Some told me it is using GPU. coregraphics is best or openGL is best, calayer is better. ^^;;;; What is different between them and which one is using GPU?? Which one is the best to make a game. I have many image to draw. Please let me know..... Thanks in advance. The iOS graphics APIs are layered

From CATransform3D to CGAffineTransform

戏子无情 提交于 2019-12-03 16:03:52
I'm using the following function to apply a pulse effect to a view - (void)pulse { CATransform3D trasform = CATransform3DScale(self.layer.transform, 1.15, 1.15, 1); trasform = CATransform3DRotate(trasform, angle, 0, 0, 0); CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"transform"]; animation.toValue = [NSValue valueWithCATransform3D:trasform]; animation.autoreverses = YES; animation.duration = 0.3; animation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]; animation.repeatCount = 2; [self.layer addAnimation:animation forKey:

CALayer opacity animation

一笑奈何 提交于 2019-12-03 15:14:45
问题 I want to create a CALayer animation that gives sort of a 'flashy' effect. For that I'm trying to animate the 'opacity' property, but my problem is that I have no idea where to start and how to do it. Here is a graphical explanation of the animation: opacity | ___ 1 | | | | | | * repeatCount 0 |___| |_ . . . -------------------------> time |______| duration The opacity starts at 0, then animates to 1, then to 0 again (this 0-to-1-to-0 animation takes a number of seconds equal to duration).