草庐IT

shapelayer

全部标签

ios - 如何在不显示轴的情况下绘制水平条形图

我需要实现一个类似于下图的水平条形图。在这里我不需要随图一起显示轴,但我仍然需要想象有一个轴:我怎样才能做到这一点? 最佳答案 您可以使用带有CAShapeLayer的UIBezierPath可以使用下面的函数来绘制单杠funcdrawLine(startpointstart:CGPoint,endpintend:CGPoint,linecolorcolor:CGColor,linewidthwidthline:CGFloat){varpath=UIBezierPath()path.moveToPoint(start)path.ad

ios - 带阴影的线圆

我正在尝试绘制一个带有阴影的描边颜色的空圆。letbezierPath=UIBezierPath(ovalIn:CGRect(x:80,y:200,width:100,height:100))letshapeLayer=CAShapeLayer()shapeLayer.path=bezierPath.cgPathshapeLayer.fillColor=UIColor.clear.cgColorshapeLayer.strokeColor=UIColor.white.cgColorshapeLayer.lineWidth=3shapeLayer.shadowPath=bezierPat

objective-c - 有弹性的 UIBezierPath 线?

我想用我的手指画一条直线,它会根据我离原点的距离自动调整大小。因此,如果我触摸屏幕中间并将手指滑出,则当我的手指在屏幕上移动时,一条线似乎会“拉伸(stretch)”并围绕原点旋转。当我抬起手指时。目的地点应该最终确定并创建一条线。我可以在屏幕上拖动手指并在屏幕上“绘图”,但这不是我想要做的。我认为UIBeizerPathmoveToPoint会有所帮助,但它只会把事情搞砸。我做错了什么?-(id)initWithFrame:(CGRect)frame{//defaultlinepropertiesmyPath=[[UIBezierPathalloc]init];myPath.line

objective-c - 使用 CABasicAnimation 为 CAShapeLayer 的 strokeColor 设置动画

使用thisprevious中的答案,我未能在CAShapeLayer上设置闪烁笔画的动画效果线程,经过多次搜索后,我找不到使用CABasicAnimation为笔画设置动画的其他示例。我想要做的是让我的CAShapeLayer脉冲在两种颜色之间。将CABasicAnimation用于不透明度效果很好,但[CABasicAnimationanimationWithKeyPath:@"strokeColor"]让我望而却步,我很感激任何关于如何成功实现的建议。CABasicAnimation*strokeAnim=[CABasicAnimationanimationWithKeyPath

ios - 如何在修改路径时重绘 CAShapeLayer?

我正在尝试向我的CAShapeLayer路径添加一个子路径,但更改不会显示,除非我首先将nil赋给路径,然后我将myPath重新分配给CAShapeLayer。我试过setNeedsRedisplay但它不起作用。这是LoadView中的代码,其中myPath和shapeLayer是属性://TheCGMutablePathRefCGPathMoveToPoint(myPath,nil,self.view.center.x,self.view.center.y);CGPathAddLineToPoint(myPath,nil,self.view.center.x+100.0,self.

ios - 如何删除两个 CGpoint 之间的线?

当用户触摸屏幕并拖动手指时,我正在ipad中创建一条线。问题是线是在我们拖动它的(touchMoved:)中的每个点上创建的。但最后应该只有一个不多。创建新行后如何删除或删除最后一行?这是我的代码:-(void)touchesMoved:(NSSet*)toucheswithEvent:(UIEvent*)event{if(ArrowDraw==YES){NSLog(@"ArrowDrawing");if([[eventallTouches]count]==1){UITouch*touch=[touchesanyObject];CGPointcurrentPoint=[touchloc

iphone - UIView 子类中使用的 CAShapeLayer 不起作用

我尝试了几个小时来使用CAShapeLayer在我的UIView周围添加一个虚线边框,但我没有显示它。ScaleOverlay.h#import#import@interfaceScaleOverlay:UIView{CAShapeLayer*shapeLayer_;}@endScaleOverlay.m-(id)initWithFrame:(CGRect)frame{self=[superinitWithFrame:frame];if(self){self.backgroundColor=[UIColorredColor];self.alpha=0;//Roundcorners[[s

ios - 在 iOS 中使用触摸绘制水平或垂直线

我正在做一个项目,我希望如果用户触摸在水平方向移动,那么应该绘制水平线,如果用户触摸在垂直方向移动,那么应该绘制垂直线。请建议一些使用Swift的解决方案。我在下面试过。但这是画自由线。overridefunctouchesBegan(_touches:Set,withevent:UIEvent?){super.touchesBegan(touches,with:event)lettouch:AnyObject?=touches.firstletlastPoint=touch!.previousLocation(in:holderView)path.move(to:CGPoint(x:

swift - 如何删除进度条圈中的 CAShapeLayer

我有以下代码,我正在实现以下载带有进度圈的PDF。它对我有用,首先我检查文件是否已保存在“文档”目录中,如果是,我只显示PDF,如果尚未加载pdf文件,则begindDownloadFile()lassViewController:UIViewController,URLSessionDownloadDelegate{@IBOutletweakvarpdfView:PDFView!leturlString="https://d0.awsstatic.com/whitepapers/KMS-Cryptographic-Details.pdf"letshapeLayer=CAShapeLa

ios - 在 Swift 4 中绘制多条线

在Swift4中,借助XcodeIDE,我可以轻松地使用以下代码绘制圆圈:letcirclePath=UIBezierPath(arcCenter:CGPoint(x:100,y:100),radius:50,startAngle:CGFloat(0),endAngle:CGFloat(Double.pi*2),clockwise:true)letshapeLayer=CAShapeLayer()shapeLayer.path=circlePath.cgPathshapeLayer.fillColor=UIColor.white.cgColorshapeLayer.strokeColo