setStroke()
方法. setstroke()具有以下声明: func setstroke()
Sets the color of subsequent stroke operations to the color that the receiver represents.
因此,您可以使用这样的setstroke():
strokecolor.setstroke() // where strokecolor is a `UIcolor` instance
下面的游乐场代码显示了如何在UIBezIErPath旁边使用setstroke(),以便在UIVIEw子类中绘制一个绿色填充颜色和浅灰色笔画颜色的圆圈:
import UIKitimport PlaygroundSupportclass MyVIEw: UIVIEw { overrIDe func draw(_ rect: CGRect) { // UIBezIErPath let newRect = CGRect( x: bounds.minX + ((bounds.wIDth - 79) * 0.5 + 0.5).rounded(.down),y: bounds.minY + ((bounds.height - 79) * 0.5 + 0.5).rounded(.down),wIDth: 79,height: 79 ) let ovalPath = UIBezIErPath(ovalIn: newRect) // Fill UIcolor.green.setFill() ovalPath.fill() // stroke UIcolor.lightGray.setstroke() ovalPath.linewidth = 5 ovalPath.stroke() }}let myVIEw = MyVIEw(frame: CGRect(x: 0,y: 0,wIDth: 200,height: 300))PlaygroundPage.current.liveVIEw = myVIEw总结
以上是内存溢出为你收集整理的ios – 如何在Swift中更改UIBezierPath的颜色?全部内容,希望文章能够帮你解决ios – 如何在Swift中更改UIBezierPath的颜色?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)