cabasicanimation

Animate infinite scrolling of an image in a seamless loop not working when back from back ground [duplicate]

天大地大妈咪最大 提交于 2019-12-25 01:53:58
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: Animate infinite scrolling of an image in a seamless loop I have the following code that run an endless loop of the same image the problem is when the user minimize the application, and get back to it, the image stop animating and it totally disappear Here is my code: -(void)cloudScroll { UIImage *cloudsImage = [UIImage imageNamed:@"TitleClouds.png"]; UIColor *cloudPattern = [UIColor colorWithPatternImage

Swift -Animation in GradientLayer not appearing in cell

こ雲淡風輕ζ 提交于 2019-12-25 01:16:00
问题 I have different images of different foods that I add to a UIView (I choose to use an UIView instead of an UIImageView ). The original color of the images are black and I change them to .lightGray using .alwaysTemplate . // the imageWithColor function on the end turns it .lightGray: [https://stackoverflow.com/a/24545102/4833705][1] let pizzaImage = UIImage(named: "pizzaImage")?.withRenderingMode(.alwaysTemplate).imageWithColor(color1: UIColor.lightGray) foodImages.append(pizzaImage) I add the

CAShapeLayer custom property is nil when drawInContext

半城伤御伤魂 提交于 2019-12-24 09:16:08
问题 I denfined a custom layer,and declare a custom property,but it's not work when animation in -(void)drawInContext:(CGContextRef)ctx method here is some code: @interface ZBBProgressLayer : CAShapeLayer @property (nonatomic, assign) CGFloat progress; @property(nullable) CGColorRef progressColor; @end @implementation ZBBProgressLayer + (BOOL)needsDisplayForKey:(NSString *)key{ if ([key isEqualToString:@"progress"]/*progress 属性变化时,重绘*/) { return YES; } return [super needsDisplayForKey:key]; } -

Get instant value of a CABasicAnimation

你说的曾经没有我的故事 提交于 2019-12-24 07:35:19
问题 While i'm implementing a game, i'm just front of a matter, whose really easy i think, but don't know how to fix it. I'm a bit new in objective-c as you could see with my reputation :( The problem is, i have an animation, which works correctly. Here is the code : CABasicAnimation * bordgauche = [CABasicAnimation animationWithKeyPath:@"transform.translation.x"]; bordgauche.fromValue = [NSNumber numberWithFloat:0.0f]; bordgauche.toValue = [NSNumber numberWithFloat:749.0f]; bordgauche.duration =

I want to draw a Smooth animations in iOS using CAPropertyAnimations

自古美人都是妖i 提交于 2019-12-23 03:46:17
问题 it works like this I want to show a circle animation. it become bigger gradually. I don't want to change it's position. my code is as following, and the circle's position also moves, how can deal with this. - (void)viewDidLoad { [super viewDidLoad]; int radius = 20; CGPoint drawPoint = CGPointMake(self.view.frame.size.width/2 -radius,self.view.frame.size.height/2+radius*2); CAShapeLayer *circle = [CAShapeLayer layer]; // Make a circular shape circle.path = [UIBezierPath

How do I animate opacity using swift?

北城余情 提交于 2019-12-19 18:28:46
问题 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

How to animate borderColor change in swift

点点圈 提交于 2019-12-19 18:25:44
问题 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. 回答1: 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

Animate a layer property which simply changes other properties?

半城伤御伤魂 提交于 2019-12-19 07:07:13
问题 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

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

﹥>﹥吖頭↗ 提交于 2019-12-18 13:54:15
问题 This question already has answers 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) Closed 2 years ago . 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

Animating CAShapeLayer size change

随声附和 提交于 2019-12-17 22:34:36
问题 I am drawing a circle, with an initial radius of 200 self.circle = [CAShapeLayer layer]; self.circle.fillColor = nil; self.circle.strokeColor = [UIColor blackColor].CGColor; self.circle.lineWidth = 7; self.circle.bounds = CGRectMake(0, 0, 2 * radius, 2 * radius); self.circle.path = [UIBezierPath bezierPathWithArcCenter:CGPointMake(self.radius, self.radius) Can anyone please tell me how to animate a change to a radius of 100? 回答1: This is how I ended up doing it: UIBezierPath *newPath =