CAShapeLayer填充颜色swift 4 xcode 9 iOS 11不工作任何想法?

问题描述 投票:-1回答:1

我一直在尝试使用Swift 4填充XCode 9 iOS 11中的CAShapeLayer颜色,但没有成功。

let circlePath = UIBezierPath(arcCenter: CGPoint(x: 0, y: 0), radius: 12, startAngle: 0.0, endAngle: CGFloat(Double.pi * 2.0), clockwise: true)
let circleLayer = CAShapeLayer()
circleLayer.path = circlePath.cgPath
circleLayer.fillColor = UIColor.red.cgColor
circleLayer.strokeColor = UIColor.white.cgColor
circleLayer.lineWidth = 1.5
ios swift ios11 swift4 cashapelayer
1个回答
0
投票

也许,你忘了设置一个框架。例如:

circleLayer.frame = CGRect(x: 6, y: 6, width: 12, height: 12)
© www.soinside.com 2019 - 2024. All rights reserved.