cabasicanimation

Fade background-color from one color to another in a UIView

人走茶凉 提交于 2019-12-03 08:01:07
How can I fade from one background-color to another color in a UIView? In javascript (jQuery) it can be done by doing the following: $('body').animate({ backgroundColor: "#ff00ff"}); Would it be easier if I converted the colors to HSV? EDIT: Tried to do it with CABasicAnimation but it flashes white for unknown reasons. :/ CABasicAnimation* fade = [CABasicAnimation animationWithKeyPath:@"backgroundColor"]; fade.fillMode = kCAFillModeForwards; fade.removedOnCompletion = NO; // fade.fromValue = (id)[self.view backgroundColor].CGColor; fade.toValue = (id)[UIColor greenColor].CGColor; [self.view

Trying to delay CABasicAnimation position and opacity of layer by 3 seconds but

Deadly 提交于 2019-12-03 06:12:11
I am trying to delay the animation of layer's opacity and position by 3 seconds using setBeginTime. I have called the layer boxLayer. The animation is going well however during the first 3 seconds (the layer is not supposed to show yet) the layer is displayed at its final position and opacity. It should not. Group animation does not resolve the issue. Could anyone help? See code below: // Create an animation that will change the opacity of a layer CABasicAnimation *fader = [CABasicAnimation animationWithKeyPath:@"opacity"]; // It will last 1 second and will be delayed by 3 seconds [fader

CABasicAnimation unlimited repeat without HUGE_VALF?

£可爱£侵袭症+ 提交于 2019-12-02 21:41:50
I'm trying to perform auto repeat of my image rotation animation with CABasicAnimation. I have tried to search on web how to set such property but was unable to find that. Is it really no such property for CA animation? I know that you can set some huge value ( here ) to repeatCount property but hey, why then does UIView animateWithDuration has an option UIViewAnimationOptionRepeat and what the value is hardcoded for it? No, this is the way you're supposed to do it according to the documentation . Setting this property to HUGE_VALF will cause the animation to repeat forever. Update for Swift:

How do I animate opacity using swift?

不羁的心 提交于 2019-12-01 18:01:07
Could someone please provide me with an example of animating the opacity of an Image View in swift?? I couldn't even find a good example in objective c func showCorrectImage(element: AnyObject){ var animation : CABasicAnimation = CABasicAnimation(keyPath: "opacity"); animation.delegate = self animation.fromValue = NSValue(nonretainedObject: 0.0) animation.toValue = NSValue(nonretainedObject: 1.0) animation.duration = 1.0 element.layer?.addAnimation(animation, forKey: nil) } I think I have most of this right (not completely sure though), could someone please help me? element = an Image View

How to animate borderColor change in swift

心已入冬 提交于 2019-12-01 17:51:50
For some reason this isn't working for me: let color = CABasicAnimation(keyPath: "borderColor") color.fromValue = sender.layer.borderColor; color.toValue = UIColor.redColor().CGColor; color.duration = 2; color.repeatCount = 1; sender.layer.addAnimation(color, forKey: "color and width"); I'm not getting any animation to occur. You have to use the same key name. You also forgot to add a border width and color to your layer before animating it. Try like this: let color = CABasicAnimation(keyPath: "borderColor") @IBAction func animateBorder(sender: AnyObject) { color.fromValue = UIColor.greenColor

Animate a layer property which simply changes other properties?

心已入冬 提交于 2019-12-01 04:58:46
Imagine a CAGradientLayer . It's very easy to animate .startPoint and .endPoint . Now imagine a float spinLike which simply sets both of them at once . {So, instead of having two different animations, you could simply animate spinLike .} So something like .. class CustomGradientLayer: CAGradientLayer { @objc var spinLike: CGFloat = 0 { didSet { startPoint = CGPoint( ... ) endPoint = CGPoint( ... ) setNeedsDisplay() } } } To animate spinLike ... class Test: UIView { ... g = CustomGradientLayer() a = CABasicAnimation(keyPath: "spinLike") ... g.add(a, forKey: nil) ... But. It doesn't work,

How to make UI object responsive after CABasicAnimation

柔情痞子 提交于 2019-11-30 12:35:33
问题 I'm having trouble trying to find a way to make my UI object (UISegmentedControl) touch responsive after a CABasicAnimation slide in and bounce. How can I pull this off? I know the UI object is in the presentation tree after the move. But I really like the setTimingFunction feature CABasicAnimation provides and I just won't be able to get such a smooth bounce using UIView animation. Example GIF of animation (Looped): Code I'm using inside viewDidLoad CABasicAnimation *startAnimation =

UIBezierPath + CAShapeLayer - animate a circle filling up [duplicate]

我的未来我决定 提交于 2019-11-30 10:26:21
This question already has an answer here: Draw part of a circle 8 answers iPhone Core Animation - Drawing a Circle 4 answers iOS: How to draw a circle step by step with NSTimer 2 answers I am trying to animate the paths of a CAShapeLayer so that I get the effect of a circle "filling" up to a specific amount. The Issue It "works", but is not AS smooth as I think it could be, and I want to introduce some easing to it. But because I'm animating each % individually, I'm not sure that's possible right now. So I'm looking for alternatives that could solve this issue! Visual Explanation To start --

CABasicAnimation with CALayer path doesn't animate

笑着哭i 提交于 2019-11-30 07:52:50
问题 I'm trying to animation the transition of a CALayer from normal corners to rounded corners. I only want to round the top corners, so I am using a UIBezierPath. Here's the code: UIRectCorner corners = UIRectCornerTopLeft | UIRectCornerTopRight; UIBezierPath* newPath = [UIBezierPath bezierPathWithRoundedRect:self.bounds byRoundingCorners:corners cornerRadii:CGSizeMake(8.0f, 8.0f)]; UIBezierPath* oldPath = [UIBezierPath bezierPathWithRoundedRect:self.bounds byRoundingCorners:corners cornerRadii

How do I simultaneously animate a UIImageView's image and the UIImageView itself?

为君一笑 提交于 2019-11-30 07:20:19
问题 The title may not be so clear, but what I want to do is to make the UIImageView display a series of images (sort of like a gif) and I do this by setting the animationImages to an array of images and then calling [imageView startAnimating]; . This works fine. I also have code that moves the UIImageView around with a CABasicAnimation, and this animation code also works fine. However, when I try to both animate the images of the UIImageView and try to move the UIImageView around, the images of