美文网首页
swift draw

swift draw

作者: 松龄学编程 | 来源:发表于2020-07-22 21:26 被阅读0次
let circleWH: CGFloat = 10
    var progress: CGFloat = 1
let con = UIGraphicsGetCurrentContext()!
        
        let centerX = (rect.width - circleWH * progress) / 2
        let centerY = (rect.height - circleWH * progress) / 2
        
        let gap: CGFloat = 8
        
        // top left
        con.addEllipse(in:
            CGRect(
                x: centerX - gap,
                y: centerY - gap,
                width: circleWH * progress,
                height: circleWH * progress))
        
        // top right
        con.addEllipse(in:
            CGRect(
                x: centerX + gap,
                y: centerY - gap,
                width: circleWH * progress,
                height: circleWH * progress))
        
        // bottom left
        con.addEllipse(in:
            CGRect(
                x: centerX - gap,
                y: centerY + gap,
                width: circleWH * progress,
                height: circleWH * progress))
        
        // bottom right
        con.addEllipse(in:
            CGRect(
                x: centerX + gap,
                y: centerY + gap,
                width: circleWH * progress,
                height: circleWH * progress))
        
        con.setFillColor(themeColor.cgColor)
        con.fillPath()

相关文章

网友评论

      本文标题:swift draw

      本文链接:https://www.haomeiwen.com/subject/dqqxlktx.html