Tag: 梯度

编译错误尝试使用CAGradientLayer

我试图使用CAGradientLayer并获得无益的编译错误。 无法弄清楚什么是错的。 我到目前为止所做的是: CAGradientLayer *gradient = [CAGradientLayer layer]; 我已经导入了<QuartzCore/QuartzCore.h> ,我得到了警告> _OBJC_CLASS_ $ CAGradientLayer引用自:objc-class-ref-to-CAGradientLayer符号(s)not found。 我试过干净,但没有运气,我似乎无法在Xcode中的目标以外的任何其他4.1 欢呼任何帮助。

沿着弯曲的UIBezierPath绘制渐变

在应用程序中,我绘制了一个弯曲的UIBezierPath和一个MKOverlayPathView类来显示航线。 这是我正在使用的代码: – (UIBezierPath *)pathForOverlayForMapRect:(MKMapRect)mapRect { … bla bla bla … UIBezierPath *path = [UIBezierPath bezierPath]; [path moveToPoint:s]; [path addQuadCurveToPoint:e controlPoint:cp1]; [path addLineToPoint:e2]; [path addQuadCurveToPoint:s2 controlPoint:cp2]; [path closePath]; return path; } – (void)drawMapRect:(MKMapRect)mapRect zoomScale:(MKZoomScale)zoomScale inContext:(CGContextRef)context{ self.mapRect = mapRect; CGContextSetRGBFillColor(context, 1.0, 1.0, 1.0, 1.0); CGContextSetRGBStrokeColor(context, 0.0, 0.0, 0.0, 1.0); CGContextSetLineWidth(context, mapRect.size.height/700); CGContextSetLineJoin(context, kCGLineJoinRound); CGContextSetLineCap(context, kCGLineCapRound); CGContextAddPath(context, […]

Swift:沿着贝塞尔path渐变(使用CALayers)

我有一个相对直观的实现与CALayer对象设置的进度视图。 进度视图本身是UIView的子视图。 以下是设置进度环的代码: self.progressRingLayer = CAShapeLayer() let innerRect = CGRectInset(bounds, CGFloat(self.lineWidth) / 2, CGFloat(self.lineWidth) / 2) let innerPath = UIBezierPath(ovalInRect: innerRect) self.progressRingLayer.path = innerPath.CGPath self.progressRingLayer.fillColor = UIColor.clearColor().CGColor self.progressRingLayer.strokeColor = kProgressColor.CGColor self.progressRingLayer.anchorPoint = CGPointMake(0.5, 0.5) self.progressRingLayer.transform = CATransform3DRotate(self.progressRingLayer.transform, (CGFloat(M_PI))*1, 0, 0, 1) self.progressRingLayer.lineCap = kCALineCapRound self.progressRingLayer.lineWidth = CGFloat(self.lineWidth) self.layer.addSublayer(self.progressRingLayer) 我现在要做的就是向progressRingLayer添加一个渐变(跟随(或弯曲))path。 我已经成功地为填充添加线性渐变,但不是仅添加到path。 这里是我想要什么效果的一个例子: 到目前为止,我发现的所有东西都需要一些CoreGraphics和CGContext的附加步骤,这些步骤不太适合我的实现。 任何帮助将是伟大的,谢谢!