你正在给予addArcWithCenter
以度为单位的角度:
maskingPath.addArcWithCenter(CGPoint(x: half, y: half),
radius: half,
startAngle: 0,
endAngle: 360,
clockwise: true)
but 文档 https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIBezierPath_class/#//apple_ref/occ/instm/UIBezierPath/addArcWithCenter:radius:startAngle:endAngle:clockwise:指出角度应以弧度为单位。
因此,您正在创建一条自身重叠多次的路径。该边缘绘制在该边缘的先前通道之上的同一位置。在积累了足够多的通道后,它们最终看起来不透明(或几乎不透明)。如果您在彼此之上创建多个圆形路径,您会看到类似的内容。
这对我来说效果更好:
maskingPath.addArcWithCenter(CGPoint(x: half, y: half),
radius: half,
startAngle: 0,
endAngle: CGFloat(M_PI * 2.0),
clockwise: true)
(但是由于您确实想要一个封闭的椭圆形,因此您应该使用UIBezierPath(ovalInRect: targetView.bounds)
,正如您在回答中所做的那样。)