I’m trying to achieve this design in iOS UIKit
Using bezier path I have completed it but I am unable to achieve the inverted curve from the left side.
I’m using two shape layers, one for the circle in the left side and one for the arcShape in the right side.
2
Answers
The result is close to the depicted design. The left circle may need to move to the left to compensate for the shape’s stroke width which extend beyond the UIBezierPath initializer’s dimensions, causing the squished appearance between the circle and the enclave.
For example:
shapeLayer.position = CGPoint(x: -strokeOffset, y: 0)
Additionally for the circle on the left, change backgroundColor here to the fill color depicted in the spec:
shapeLayer.fillColor = backgroundColor.cgColor
Using some trigonometry you can get the exact result you need no matter what size the view’s frame is. The following code is based on your original code with some changed calculations. It also allows for a user define line width and adjust itself so the stroked line is all within the confines of the view.
Here’s some example code. The above and the following can all be copied into a playground to test the results.
Here’s the output: