ios – 在UIBezierPath的两侧应用阴影

ios – 在UIBezierPath的两侧应用阴影,第1张

概述我正在画画.我得到流畅的线条,我可以改变图纸的颜色.但我找不到如何将阴影应用于该线. 为了绘制它,我使用: [path strokeWithBlendMode:[path blendMode] alpha:1.0]; 我看到我可以使用CGContextSetShadowWithColor(),但即便如此,我不知道如何使用它,因为这是在strokeWithBlendMode的CGPath参考中所说的 我正在画画.我得到流畅的线条,我可以改变图纸的颜色.但我找不到如何将阴影应用于该线.

为了绘制它,我使用:

[path strokeWithBlendMode:[path blendMode] Alpha:1.0];

我看到我可以使用CGContextSetShadowWithcolor(),但即便如此,我不知道如何使用它,因为这是在strokeWithBlendMode的CGPath参考中所说的:

This method automatically saves the current graphics state prior to
drawing and restores that state when it is done,so you do not have to
save the graphics state yourself.

所以我真的不知道如果我可以使用CGContextSetShadowWithcolor()或其他任何东西.

问候

解决方法 如果要使用CGContextSetShadowwithcolor(),则需要更改将bezIErpath绘制到视图的方式,以便将CGPath表示绘制到CGContext.一个例子如下:
UIBezIErPath *path;     // this is your path as beforeCGContextRef context = UIGraphicsGetCurrentContext();CGContextAddpath(context,path.CGPath);CGContextSetlinewidth(context,2.0);CGContextSetBlendMode(context,path.blendMode);CGContextSetShadowWithcolor(context,CGSizeMake(1.0,1.0),2.0,[UIcolor blackcolor].CGcolor);CGContextstrokePath(context);

另一种方法是创建一个新的CAShapeLayer,并通过将其设置为path属性来绘制路径.这将很容易让你添加一个只影响你的路径的阴影.

总结

以上是内存溢出为你收集整理的ios – 在UIBezierPath的两侧应用阴影全部内容,希望文章能够帮你解决ios – 在UIBezierPath的两侧应用阴影所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1113613.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-29
下一篇 2022-05-29

发表评论

登录后才能评论

评论列表(0条)

保存