iphone - 改变 CAShapeLayer 中的线宽

标签 iphone objective-c core-animation

我正在做一个小项目,我想在其中绘制一条贝塞尔曲线。我希望能够改变绘图不同部分的 lineWidth

这是我所拥有的:

CAShapeLayer *pathLayer = [CAShapeLayer layer];
pathLayer.frame = self.animationLayer.bounds;
pathLayer.bounds = pathRect;
pathLayer.geometryFlipped = YES;
pathLayer.path = path.CGPath;
pathLayer.strokeColor = [[UIColor blackColor] CGColor];
pathLayer.fillColor = nil;
pathLayer.lineWidth = 1.0f;
pathLayer.lineJoin = kCALineJoinBevel;

如何改变线条的宽度?一种解决方案可能是使用多个 UIBezierPath 和多个 CAShapeLayer,但似乎应该有一个更简单、更优雅的解决方案(类似于指定 >lineWidth 位于指定 UIBezierPath 行的级别。

谢谢!

最佳答案

UIBezierPath 只有一个 lineWidth 属性,因此不可能用一条路径绘制不同的线宽。您将不得不使用多个路径来实现此效果。

关于iphone - 改变 CAShapeLayer 中的线宽,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7843661/

相关文章:

iPhone SDK : UIButtons in UIScrollView - Resize Scroll View to Fit all Non Hidden Buttons

iphone - 同一个 ViewController 的 2 个 View

ios - 安装 iOS 应用程序后的深度链接(延迟深度链接)

iphone - 当输入文本时,UITextView 在 UIScrollView 内部滚动父级

ios - 获取用户在 Objective-C 中订阅的所有主题

ios - 将UIView视为按钮

objective-c - 分析由NSAffineTransform和CILineOverlay过滤器产生的位图

core-animation - CATransform3D 等同于 CGPointApplyAffineTransform 和 friend

iphone - 停止进行中的 CAKeyframeAnimation

iphone - 在屏幕上绘制移动语音气泡的最快/最有效的方法 - CoreAnimation、Quartz 2D?