core-animation

How to synchronize CALayer and UIView animations up and down a complex hierarchy

帅比萌擦擦* 提交于 2019-12-06 13:17:58
See How to manage CALayer animations throughout a hierarchy for a follow-up question that is concerned just with how to synchronize parent-child layer animations. This is a design question concerning running dependent animations at different levels of the view hierarchy in response to animations up the hierarchy. I have a container controller that has any number of child controllers. The parent controller organizes this content on the screen and at various points needs to change the size and positions of its children views. I'm trying to animate each of these child views to transition its size

How to detect hardware acceleration for Core Image?

旧巷老猫 提交于 2019-12-06 12:47:55
问题 In my app I'm using a "CIMotionBlur" CIFilter during CALayer animation. The problem is that the filter does not work properly when hardware acceleration is not available: In OS X Safe Mode the layer becomes invisible during animation; When using VMWare Fusion the animation is unbearably slow and makes testing the app harder; Animation works fine without the filter. I'd like to apply filter only when hardware acceleration is available. What's the highest level API that would let me know when

Core Animation window flip effect

让人想犯罪 __ 提交于 2019-12-06 12:39:57
问题 Any tutorials or sample code to get the Core Animation window flip effect? I'm using Flipr right now, which uses Core Image to generate the effect but CoreAnimation is much smoother Thanks 回答1: Mike Lee released some code for just this a while back. He called it LemurFlip. 回答2: take a look at uli kusterers windowflipper code. http://www.zathras.de/angelweb/sourcecode.htm (search for WindowFlipper) have no experience with it, but it just might work for you :) 回答3: I added some code on how I do

How can I draw and rotate an Arrow at an Orientation in 3D Space?

倾然丶 夕夏残阳落幕 提交于 2019-12-06 12:23:56
I want to draw an image like the following in a certain orientation. Assume that the device lies flat on a table the image above shows how the arrow should be drawn. The angle between the device and the table is called alpha and it is zero in this case. The arrow points straight to a predefined location point. If you rotate the device on the table the arrow will point alway to the target direction just like a compass. I did the update of the image position with the following code in 2D space: // Create the image for the compass let arrowImageView: UIImageView = UIImageView(frame: CGRectMake

animations on infinite loop

≯℡__Kan透↙ 提交于 2019-12-06 12:22:59
问题 I have 5 different animations that animate then disappear one after another. Is there a way to put them on an infinite loop so animation #1 begins and ends, then anim #2 begins and ends etc..? the whole process then would repeat on an infinite loop. I have the animations in separate blocks on delays. I'm guessing that there is a better way of doing this. this is what I have at the moment: -(void) firstAnimation { [UIView beginAnimations:@"Fade Out Image" context:nil]; [UIView

Animate the mask of a mask of a CALayer

你。 提交于 2019-12-06 11:36:14
Goal: I am drawing a custom shape that has a gradient. I also want to animate the drawing of this shape by having it draw in from left to right. Problem: The code below works on an iPad simulator, but it doesn't work on my iPad 4 running iOS 7. Does anyone know how to make this work on the device? Is there a different way to achieve this same result? Explanation of my Code: My code works (only on simulator) using 3 CALayers. gradientLayer holds my gradient. shapeMaskLayer holds my custom shape. animationMaskLayer animates it's path to simulate drawing from left to right animationMaskLayer -

How to change the frame rate of a core animation instance?

别等时光非礼了梦想. 提交于 2019-12-06 10:42:01
Take CABasicAnimation for example. How do you lower the frame rate (overhead)? Animations run smooth, but my touchesMoved method skips a beat. Want to reduce the animation frame rate so touchesMoved is not skipping movements. You don't have any inherent control over frame rate once you start your CABasicAnimation. Probably the best way to achieve this would be to create multiple interpolations for a single animation (i.e. if you're moving 50 px down and 50px across, do 2 x 25px each) and induce an artificial sleep in your thread. Not a perfect solution, but will perhaps achieve slightly better

iPhone, How do I rotate an UIImageView around a point using Core Animation and CATransform3D?

前提是你 提交于 2019-12-06 10:38:52
问题 This is what I want to do: (1) (2) | / | / | / | / |/ * (3) I want to move an UIImageView represented by a clock pin (width:9px, height 73px) from position (1) to position (2) around point (3) which is one end of the image. I tried to set the anchorpoint to (0,0) or to set the image center to point (517,177) which is the *(3) location on the iPad screen, but I had no success: My degreeToRadians macro is defined in the following way: #define degreesToRadian(x) (M_PI * (x) / 180.0) /* kmPointer

How to make image spin (animation)

a 夏天 提交于 2019-12-06 10:26:36
I have an image which is a square and I know how to make it spin. But not sure how to make it spin exactly like this animation here: Notice how it spins... then stops a little... then spins again... and so on. What I have just is a basic spin but doesn't look like the gif above: extension UIView { func rotate360Degrees(duration: CFTimeInterval = 3) { let rotateAnimation = CABasicAnimation(keyPath: "transform.rotation") rotateAnimation.fromValue = 0.0 rotateAnimation.toValue = CGFloat(M_PI * 2) rotateAnimation.isRemovedOnCompletion = false rotateAnimation.duration = duration rotateAnimation

CATransformLayer - Performance issues when setting frame of sublayers

血红的双手。 提交于 2019-12-06 09:22:06
I have a CATransformLayer which has a couple of sublayers (CAShapeLayers). I'm setting the frames of my CAShapeLayers to have a size of (512, 512). Their content is (slightly) smaller than this. When rotating the whole scene in 3D it's slowing down the frame rate - but it renders everything correctly. If I do not set the frame property of the CAShapeLayers, then it's rotating the scene in 3D super fast but there are rendering mistakes. These are: Layers disappear at certain angles Wrong z-ordering (some layers get rendered on top of each other that should be rendered the other way around) What