2016-09-06 11 views
1

私はシャープなストロークカラーで空の円を描こうとしています。影付きの円サークル

let bezierPath    = UIBezierPath(ovalIn: CGRect(x: 80, y: 200, width: 100, height: 100)) 

let shapeLayer    = CAShapeLayer() 
shapeLayer.path    = bezierPath.cgPath 
shapeLayer.fillColor  = UIColor.clear.cgColor 
shapeLayer.strokeColor  = UIColor.white.cgColor 
shapeLayer.lineWidth  = 3 
shapeLayer.shadowPath  = bezierPath.cgPath 
shapeLayer.shadowColor  = UIColor.black.cgColor 
shapeLayer.shadowOffset  = CGSize(width: 0, height: 0) 
shapeLayer.shadowOpacity = 1 

containerView.layer.addSublayer(shapeLayer) 

The result

しかし影が円全体を埋めています。どのようにそれを削除し、外側の影を維持するには?

答えて

2

ちょうどshapeLayer.shadowPathを設定省略します(基本的にレイヤーの不透明部分である層の標準的な影、)このようなものでしょう:

enter image description here