You can make a rounded circle in Swift
using CAShapeLayer
. Here's an example:
main.swift334 chars9 lines
In the code above, we create an instance of CAShapeLayer
and set its path
property to a UIBezierPath
representing an oval with a width and height of 80. We also set the fillColor
to clear
so the circle will be transparent inside, and set the strokeColor
to black
with a lineWidth
of 1.0, which gives us the rounded circle shape. Lastly, we set the lineCap
to round
to ensure the ends of the stroke are rounded, and add the layer to our yourView
. This will create a rounded circle in yourView
with a diameter of 80.
gistlibby LogSnag