swift – 如何用CALayer创建一个圈子?

swift – 如何用CALayer创建一个圈子?,第1张

概述我有下面的代码测试,但是当我给它的约束,它变成一个小圆圈: override func drawRect(rect: CGRect) {var path = UIBezierPath(ovalInRect: rect)fillColor.setFill()path.fill()//set up the width and height variables//for the horizo 我有下面的代码测试,但是当我给它的约束,它变成一个小圆圈:
overrIDe func drawRect(rect: CGRect) {var path = UIBezIErPath(ovalInRect: rect)fillcolor.setFill()path.fill()//set up the wIDth and height variables//for the horizontal strokelet plusHeight:CGfloat = 300.0let plusWIDth:CGfloat = 450.0//create the pathvar plusPath = UIBezIErPath()//set the path's line wIDth to the height of the strokeplusPath.linewidth = plusHeight//move the initial point of the path//to the start of the horizontal strokeplusPath.movetoPoint(CGPoint(  x:self.bounds.wIDth/2 - plusWIDth/2 + 0.5,y:self.bounds.height/2 + 0.5))//add a point to the path at the end of the strokeplusPath.addlinetoPoint(CGPoint(  x:self.bounds.wIDth/2 + plusWIDth/2 + 0.5,y:self.bounds.height/2 + 0.5))}
根据需要更改半径和fillcolor. 总结

以上是内存溢出为你收集整理的swift – 如何用CALayer创建一个圈子?全部内容,希望文章能够帮你解决swift – 如何用CALayer创建一个圈子?所遇到的程序开发问题。

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

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

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

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

发表评论

登录后才能评论

评论列表(0条)

保存