Tag: caanimation

核心animation中的圆形箭头蒙版的长度的animation

我已经使用CAShapeLayer和蒙版创build了一个圆形的animation。 这是我的代码: – (void) maskAnimation{ animationCompletionBlock theBlock; imageView.hidden = FALSE;//Show the image view CAShapeLayer *maskLayer = [CAShapeLayer layer]; CGFloat maskHeight = imageView.layer.bounds.size.height; CGFloat maskWidth = imageView.layer.bounds.size.width; CGPoint centerPoint; centerPoint = CGPointMake( maskWidth/2, maskHeight/2); //Make the radius of our arc large enough to reach into the corners of the image view. CGFloat radius = sqrtf(maskWidth * […]

两个贝塞尔path形状之间的animation

我发现在两个状态之间animationUIImageView是非常棘手的:原始的矩形框架和用UIBezierPath创build的新形状。 有很多不同的技术提到,其中大部分不适合我。 首先是认识到使用UIView块animation不行; 显然不能在animateWithDuration:块中执行子图层animation。 (见这里和这里 ) 这就离开了CAAnimation ,像CABasicAnimation这样的具体子类。 我很快就意识到,不能从没有CAShapeLayer的视图(例如在这里看到)创buildanimation。 而且它们不能只是任何两个形状的层path,而是“animation形状层的path只有当你从喜欢到喜欢animation时保证工作”(见这里 ) 有了这个,就会出现更多世俗的问题,比如从fromValue和fromValue (应该是CAShapeLayer还是CGPath ?),将animation添加到( layer或mask ?)等等。 似乎有这么多的变数, 哪个组合会给我我想要的animation?

需要更好,更简单地了解CATransform3D

请通过图像。 所以这是我从一些在线来源获得的代码,它改变了我的对象。 除此之外,我什么也不懂。 我是CATransform3D的新手,想知道它是如何工作的。 CATransform3D transform = CATransform3DIdentity; transform.m34 = 1.0 / -500; transform = CATransform3DRotate(transform, 45.0f * M_PI / 180.0f, 0, 1, 0.0f); _bgView.layer.transform = transform; 我想知道这个代码是如何运行的? 为什么我们在m34中设定一些价值? 我发现它的某种matrix更令我困惑。 另外, CATransform3DRotate中的参数是什么意思? 我想了解,但没有进一步。 我想深入了解CATransform3D。 请帮助任何文章,文件或解释自己。 非常感谢。

我怎样才能为多个属性创build一个CABasicAnimation?

我有这个代码来animation一个CALayer元素。 CABasicAnimation *makeBiggerAnim=[CABasicAnimation animationWithKeyPath:@"radius"]; makeBiggerAnim.duration=0.2; makeBiggerAnim.fromValue=[NSNumber numberWithDouble:20.0]; makeBiggerAnim.toValue=[NSNumber numberWithDouble:40.0]; makeBiggerAnim.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]; 我的问题是,现在一切正常,我想在同一时间的同一元素的另一个属性。 我见过你可以做添加剂animation和东西。 我的问题是: 添加剂属性是最好的/唯一的方法来做到这一点? (立刻animation同一个对象的多个属性) 谢谢!

animation在UIImage更改时快照

当按下button时,我有一个UIImageView在屏幕上运行。 当button被按下时,改变UIImageView的UIImage,当button被释放时,我将其更改为其原始的UIImage。 当图像变回时,它会回到图像开始的位置。 该button被按下时调用该定时器: //This is the image that changes when the button is pressed. imView.image = image2; runTimer = [NSTimer scheduledTimerWithTimeInterval:0.04 target:self selector:@selector(perform) userInfo:nil repeats:YES]; 这被称为当button停止时: – (IBAction)stopPerform:(id)sender{ [runTimer invalidate]; //THIS IS WHAT SNAPS THE ANIMATION BACK: //Without this the animation does not snap back imView.image = image1; } – (void)performRight{ CGPoint point0 = […]

iOS:我应该为animation添加UIViews还是CALayers?

比方说,我想添加50个图像到一个视图为animation他们的目的。 假设我正在计划使用Core Animation(例如CABasicAnimation)而不是“UIView”animation。 我最好join50个子视图还是50个子图层? 这有什么不同吗? 谢谢。

UIBezierPath + CAShapeLayer – animation圈起来填满

我正在尝试对CAShapeLayer的path进行animation处理,这样我就可以得到一个圆圈“填充”到特定数量的效果。 问题 它“起作用”,但不是我想的那么顺利,我想介绍一些缓解。 但是因为我分别为每个animation制作了一个animation,所以现在我不确定这是可能的。 所以我正在寻找可以解决这个问题的替代scheme! 视觉解释 开始 – 这里是我试图实现的animation的一些“框架”(见图像 – 从0%到25%的圆圈填充) 码 我创造了绿色的中风(外面): let ovalPath = UIBezierPath(ovalInRect: CGRectMake(20, 20, 240, 240)) let circleStrokeLayer = CAShapeLayer() circleStrokeLayer.path = ovalPath.CGPath circleStrokeLayer.lineWidth = 20 circleStrokeLayer.fillColor = UIColor.clearColor().CGColor circleStrokeLayer.strokeColor = colorGreen.CGColor containerView.layer.addSublayer(circleStrokeLayer) 我创build了填充形状(内部)的初始path: let filledPathStart = UIBezierPath(arcCenter: CGPoint(x: 140, y: 140), radius: 120, startAngle: startAngle, endAngle: Math().percentToRadians(0), clockwise: true) […]

如何绕着X轴翻转UIView,同时切换子视图

这个问题之前已经被问过了,但是方式稍有不同,我无法得到任何答案,所以我希望拥有出色核心animation技能的人能够帮助我。 我有一张桌子上的一套卡。 随着用户向上或向下滑动,该组卡片在桌子上上下移动。 在任何时候屏幕上都可以看到4张牌,但是只有第二张牌正在显示其脸部。 当用户滑动第二张卡时,将其翻转回到其面部,并且下一张卡(取决于滑动方向)落在显示其面部的位置。 我已经build立了我的卡片视图类如下所示: @interface WLCard : UIView { UIView *_frontView; UIView *_backView; BOOL flipped; } 而且我试过用这段代码翻转卡片: – (void) flipCard { [self.flipTimer invalidate]; if (flipped){ return; } id animationsBlock = ^{ self.backView.alpha = 1.0f; self.frontView.alpha = 0.0f; [self bringSubviewToFront:self.frontView]; flipped = YES; CALayer *layer = self.layer; CATransform3D rotationAndPerspectiveTransform = CATransform3DIdentity; rotationAndPerspectiveTransform.m34 = 1.0 […]

制作animation来展开和缩小UIView

我想创build一个animation,将调整UIView及其内容的一个因素。 基本上,我想制作一个animation,首先展开视图然后缩小到原始大小。 做这个的最好方式是什么? 我尝试了CALayer.contentScale,但它什么也没做。

animation期间无法获取CALayer的当前位置

我试图实现一个animation,当你按下一个button时,它将animation块放下,当你释放时,它将animation恢复到原来的位置,但无论如何我都无法获得animation块的当前位置。 这是我的代码: -(IBAction)moveDown:(id)sender{ CGRect position = [[container.layer presentationLayer] frame]; [movePath moveToPoint:CGPointMake(container.frame.origin.x, position.y)]; [movePath addLineToPoint:CGPointMake(container.frame.origin.x, 310)]; CAKeyframeAnimation *moveAnim = [CAKeyframeAnimation animationWithKeyPath:@"position"]; moveAnim.path = movePath.CGPath; moveAnim.removedOnCompletion = NO; moveAnim.fillMode = kCAFillModeForwards; CAAnimationGroup *animGroup = [CAAnimationGroup animation]; animGroup.animations = [NSArray arrayWithObjects:moveAnim, nil]; animGroup.duration = 2.0; animGroup.removedOnCompletion = NO; animGroup.fillMode = kCAFillModeForwards; [container.layer addAnimation:animGroup forKey:nil]; } -(IBAction)moveUp:(id)sender{ CGRect position […]