草庐IT

cashapelayer

全部标签

ios - 使用 CAShapeLayer 和 UIBezierPath 剪辑屏蔽 uiview

我在使用CAShapeLayer-UIBezierPath裁剪View时遇到问题,我想裁剪内容但我最终得到了那个UIBezierPath的笔划(框架),这是我的代码UIBezierPath*path2Path=[UIBezierPathbezierPath];[path2PathmoveToPoint:CGPointMake(206.745,0)];[path2PathaddLineToPoint:CGPointMake(206.745,97.613)];[path2PathaddLineToPoint:CGPointMake(0,97.613)];[path2PathaddLineT

ios - 动画绘制 CAShapeLayer 的填充

我一直在尝试使用CAShapeLayer绘制路径,如这篇精彩文章http://oleb.net/blog/2010/12/animating-drawing-of-cgpath-with-cashapelayer中所述。,但我想知道是否有办法为图层的填充设置动画。例如,我想在屏幕上绘制一些文本,但我只能绘制文本的描边,而不能绘制填充。另一个例子,我有一个星形,我想为其填充动画。这可以使用CAShapeLayer或其他对象吗?谢谢! 最佳答案 大部分时间都是相同的代码,您只需为CABasicAnimation的fromValue和to

Swift- 动画 CAshapeLayer 描边颜色

我正在尝试找到一种方法来为我正在创建的笔触的颜色设置动画circleLayer=CAShapeLayer()circleLayer.path=circlePath.CGPathcircleLayer.lineCap=kCALineCapRoundcircleLayer.fillColor=UIColor.clearColor().CGColorCABasicAnimationfill=CABasicAnimation.circleLayer.strokeColor=UIColor(red:0.4,green:1.0,blue:0.2,alpha:0.5).CGColorcircleLa

ios - CAShapeLayer 形状不显示

我的CAShapeLayer没有显示。我正在尝试通过循环CGPoints数组来创建形状。我需要使用数组或字典,以便稍后添加不同的CGPoint集来创建更复杂的形状。varshapeLayer=CAShapeLayer()varcolor=UIColor.redColor()varopenPath=UIBezierPath()varclosedPath=UIBezierPath()letpoints=[CGPoint(x:30,y:30),CGPoint(x:90,y:30),CGPoint(x:90,y:90),CGPoint(x:90,y:30),CGPoint(x:30,y:30)

ios - 缩放 CAShapeLayer 时的意外行为

我正在使用以下代码来缩放CAShapelayer实例(即self.view.layer.sublayers![0]):classViewController:UIViewController{overridefuncviewDidLoad(){super.viewDidLoad()self.view=Map(frame:CGRect(x:0,y:0,width:self.view.bounds.width,height:self.view.bounds.height))letpinchGR=UIPinchGestureRecognizer(target:self,action:#sel

ios - 动画 CAShapeLayer/CAGradientLayer

这是对我昨天提出的问题的补充。结果完美,但我想要修改。UsingdrawRecttodraw&animatetwographs.Abackgroundgraph,andaforegroundgraph下面的代码基于上面的线程,生成了一个CABasicAnimation来生成深蓝色“三角形”。我希望它不是深蓝色纯色,而是具有3个色标的CAGradientLayer:红/绿/蓝。我尝试添加一个CAGradientLayer来配置渐变,然后使用addSubLayer将渐变添加到动画出来的CAShapeLayer。我在下面发布的结果没有动画。颜色和形状保持不变。渐变看起来不错,只需要它动画出来

ios - 圆形路径中的动画线形 CAShapeLayer

我正在尝试沿着圆形路径为我的线形CAShapeLayer设置动画。我创建了线层的初始路径和最终路径,并将它们添加到CABasicAnimation的from和to值中。但是动画并不是我所期待的。我在过去2天里被困在这里。funcgetAllLayers()->[CALayer]{varlayers=[]letpointerEndPoint=CGPoint(x:xPointOfPointer,y:yPointOfPointer)//Finalendpointofpointerletradius=5letpointerFinalPath=UIBezierPath()pointerFinal

ios - 使用 CAShapeLayer 和 CAGradientLayer 提高渐变边框的性能

我正在使用此方法将渐变边框应用于View。但是,当View位于表格View的单元格中时,表格View的滚动帧率会显着下降。有没有办法提高性能?我尝试按照Apple的建议将opaque、drawsAsynchronously和shouldRasterize设置为true但没有任何改变。funcaddBorder(colors:[UIColor]?=nil,size:CGSize?=nil){_=self.sublayers?.filter({$0.name=="GradientBorder"}).map({$0.removeFromSuperlayer()})letshapeFrame=

ios - 用 CAShapeLayer 画一条线

我想显示这样一行:这是我的代码:importUIKit@IBDesignableclassProgressView:UIView{letπ=CGFloat(M_PI)varlevelProgress:CGFloat=0.0{didSet{self.fgLayer.strokeEnd=levelProgress}}letbgLayer=CAShapeLayer()letfgLayer=CAShapeLayer()@IBInspectablevarbgColor:UIColor=UIColor.black.withAlphaComponent(0.3){didSet{configure()

swift - 在 Swift 中为 CAShapeLayer 路径从旧值到新值设置动画

我是CoreAnimation的新手,我正在尝试将CAShapeLayer的strokeEnd从旧值更新为新的更新值,基于新数据。所以基本上我有一个绘制的CAShapeLayer,并更新它的UIBezierPath,并使用CABasicAnimation(forKey:"strokeEnd")来制作动画新的strokeEnd通过这样做:layerAnimation=CABasicAnimation(keyPath:"strokeEnd")layerAnimation.toValue=1shapeLayer.strokeEnd=1layerAnimation.duration=0.4sh