core-animation

What are Layers good for? What could I do with adding an Layer, and why should I think about Layers?

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-03 03:55:31
I am wondering what makes Layers different from Views, when every View comes along with it's own Layer. Maybe I am wrong with that. But then: What are these Layers good for? Like I understand it, I would use an UIView to group elements in my GUI. I could also use that UIView to position things over other things. So where come Layers into place here? Should I think of them just as the z-index like in HTML / CSS? Are they just interesting for Core Animation stuff? Compared to UIVIews, CALayers are lightweight filled with timing information for animation Some things are harder to draw, like text

NSLayoutConstraint.constant ignoring animation

北城以北 提交于 2019-12-03 03:52:58
问题 I'm creating an autolayout-friendly split view class for one of my applications. Among its various features is that it can collapse panes, and can animate their collapse, much as you might have seen NSSplitView do. Since I'm using constraints, I'm achieving this by placing a required width = (current width) constraint on the pane, and then setting the constraint's constant to 0 in an animated fashion: - (NSLayoutConstraint*)newHiddenConstraintAnimated:(BOOL)animated { NSLayoutConstraint *

How to move a view along a curved path in iOS

人盡茶涼 提交于 2019-12-03 03:19:38
How to animate/move the view in the curve path, is it possible to do using UIAnimation. Like moving a view in the path as in the image. Julio Gorgé You can do it using Core Animation and CAKeyFrameAnimation to define the curve points. See this tutorial: http://nachbaur.com/2011/01/07/core-animation-part-4/ Above one can be achived by:- i) CAKeyframeAnimation ii) Create Curve Path iii)Animate layer of Custom View import UIKit import CoreGraphics class ViewController: UIViewController { var moveAlongPath:CAAnimation! override func viewDidLoad() { super.viewDidLoad() addAnimation()

UIView appereance from bottom to top and vice versa(Core Animation)

时间秒杀一切 提交于 2019-12-03 03:00:28
My goal is to understand and implement feature via Core Animation. I think it's not so hard,but unfortunately i don't know swift/Obj C and it's hard to understand native examples. Visual implementation So what exactly i want to do(few steps as shown on images): 1. 2. 3. 4. And the same steps to hide view(vice versa,from top to bottom) until this : Also,i want to make this UIView more generic,i mean to put this UIView on my StoryBoard and put so constraints on AutoLayout(to support different device screens). Any ideas? Thanks! You can use like this Extension extension UIView{ func animShow(){

Trim/subtract CGPath from CGPath?

≡放荡痞女 提交于 2019-12-03 03:00:04
I have some CGPath (a poly with two circle) carried out on a CAShapeLayer . Can I trim/subtract paths like this? Instead of do the math, the result can be achieved at drawing time using kCGBlendModeClear . // Create the poly. CGContextBeginPath(context); CGContextMoveToPoint (context, a_.x, a_.y); CGContextAddLineToPoint (context, b_.x, b_.y); CGContextAddLineToPoint (context, c_.x, c_.y); CGContextAddLineToPoint (context, d_.x, d_.y); CGContextClosePath(context); // Draw with the desired color. CGContextSetFillColorWithColor(context, self.color.CGColor); CGContextFillPath(context); // Create

How to animate the drawing of a CGPath?

这一生的挚爱 提交于 2019-12-03 02:55:43
I am wondering if there is a way to do this using Core Animation. Specifically, I am adding a sub-layer to a layer-backed custom NSView and setting its delegate to another custom NSView. That class's drawInRect method draws a single CGPath: - (void)drawInRect:(CGRect)rect inContext:(CGContextRef)context { CGContextSaveGState(context); CGContextSetLineWidth(context, 12); CGMutablePathRef path = CGPathCreateMutable(); CGPathMoveToPoint(path, NULL, 0, 0); CGPathAddLineToPoint(path, NULL, rect.size.width, rect.size.height); CGContextBeginPath(context); CGContextAddPath(context, path);

How do I create a custom page curl Core Animation?

*爱你&永不变心* 提交于 2019-12-03 02:52:09
I'm trying to create a "page curl" animation of an image in my iPhone application. I t UIViewAnimationTransitionCurlUp, and it's undocumented Core Animation siblings, however the image I need to animate is a transparent PNG, with "uneven" (some alpha pixels) outlines. When using the aforementioned pre-made transition, those alpha pixels are painted black as soon as the animation starts, which looks terribly ugly. Therefore, I seek to create a Core Animation of my own. I have tried to research the subject, but have been unable to find a good overview of the techniques involved. The

Is it possible to play a path backwards in a CAKeyFrameAnimation?

半城伤御伤魂 提交于 2019-12-03 02:50:29
I want to animate the position of a CALayer based on a CGPath, but I want to play it backwards. Is there any way to animate a path backwards, or reverse a CGPath? animation.speed = -1; ? This may not be the best solution, but it worked for me. I told the animation to autoreverse, then started it halfway in. But to prevent it from animating back again I needed to terminate it early. - (void) animate { CAKeyframeAnimation * pathAnimation = [CAKeyframeAnimation animationWithKeyPath:@"position"]; pathAnimation.path = path; pathAnimation.duration = 15.0; pathAnimation.calculationMode =

How to specify an beginTime for an animation by using CFTimeInterval?

六月ゝ 毕业季﹏ 提交于 2019-12-03 02:42:36
问题 For my understanding, beginTime can be used to say "hey, start at exactly 12:00 'o clock". But how would I tell this with an CFTimeInterval type? I thought that this one is nothing more than a kind of "float" value to specify seconds. Or what else would be then the difference to the timeOffset property that is specified in CAMediaTiming protocol? 回答1: What I missed in the docs: beginTime is in "core animation absolute time" so you've to get the current time and specify your offset from that:

Can I animate the UIScrollView contentOffset property via its layer?

吃可爱长大的小学妹 提交于 2019-12-03 02:01:45
问题 I want to zoom and scroll a UIScrollView with a CGPathRef. Because of that I assume I have to animate the UIScrollView's layer property? But which property would I animate that would make it equivalent to doing a UIView animation and setting its contentOffset property and zoomScale ? These are not properties of a CALayer. Any ideas as to how I would approach this? Again, just want to move the scrollview to a certain contentOffset and zoomScale, but not necessarily linearly from point A to