uibezierpath

Shadow on UIView layer

我的梦境 提交于 2021-02-07 06:34:04
问题 I've make a path in order to mask my view: let path = // create magic path (uiview bounds + 2 arcs) let mask = CAShapeLayer() mask.path = path.cgPath view.layer.masksToBounds = false view.layer.mask = mask Up to here all ok. Now I would like to add a shadow that follows path, is it possibile? I try in several way, the last one is: mask.shadowPath = path.cgPath mask.shadowColor = UIColor.red.cgColor mask.shadowOffset = CGSize(width: 10, height: 2.0) mask.shadowOpacity = 0.5 But this produce a

Rounding the edges of a stroke in bezier path circle in swift

谁说胖子不能爱 提交于 2021-01-21 01:41:52
问题 I'm trying to draw a circle using UIBezierPath(ovalInRect: CGRectMake()) . Then I'll change the strokeEnd property. When this happens, either end of the circular line have sharp corners. Is there any way to round out these corners? (I would like to make the beginning and end of this line curved) 回答1: Assuming you are using a CAShapeLayer to draw this, just set the lineCap , e.g.: layer.lineCap = .round 回答2: For drawRect based solutions use lineCapStyle let path = UIBezierPath(...) path

Rounding the edges of a stroke in bezier path circle in swift

烂漫一生 提交于 2021-01-21 01:41:31
问题 I'm trying to draw a circle using UIBezierPath(ovalInRect: CGRectMake()) . Then I'll change the strokeEnd property. When this happens, either end of the circular line have sharp corners. Is there any way to round out these corners? (I would like to make the beginning and end of this line curved) 回答1: Assuming you are using a CAShapeLayer to draw this, just set the lineCap , e.g.: layer.lineCap = .round 回答2: For drawRect based solutions use lineCapStyle let path = UIBezierPath(...) path

UIBezierPath Star with rounded corners

↘锁芯ラ 提交于 2021-01-05 07:04:32
问题 I have created a star shape image by UIBezierPath using this code: let path = UIBezierPath() let center = CGPoint(x: rect.width / 2.0, y: rect.height / 2.0) let xCenter: CGFloat = center.x let yCenter: CGFloat = center.y let w = rect.width let r = w / 2.0 let flip: CGFloat = -1.0 // use this to flip the figure 1.0 or -1.0 let polySide = CGFloat(5) let theta = 2.0 * Double.pi * Double(2.0 / polySide) path.move(to: CGPoint(x: xCenter, y: r * flip + yCenter)) for i in 1..<Int(polySide) { let x:

UIBezierPath Star with rounded corners

陌路散爱 提交于 2021-01-05 07:04:27
问题 I have created a star shape image by UIBezierPath using this code: let path = UIBezierPath() let center = CGPoint(x: rect.width / 2.0, y: rect.height / 2.0) let xCenter: CGFloat = center.x let yCenter: CGFloat = center.y let w = rect.width let r = w / 2.0 let flip: CGFloat = -1.0 // use this to flip the figure 1.0 or -1.0 let polySide = CGFloat(5) let theta = 2.0 * Double.pi * Double(2.0 / polySide) path.move(to: CGPoint(x: xCenter, y: r * flip + yCenter)) for i in 1..<Int(polySide) { let x: