I gave myself an exercise to learn Swift, based on an example I have found on the Apple Swift website:
As you can see there's a river and a few dots in it right in the middle, forming a path. So I have started looking for a similar river image on the internet and I have created a Xcode playground. This is what I have now:
So basically I have an UIView
with a subview consisting in the river image I have found and a dot made with UIBezierPath
.
My first question is: is this the right way to drawn on to a UIView? I mean using a UIBezierPath
. And my second question is: how do I draw the dot at a precise coordinate inside the UIView
? (UIBezierPath
or everything else?)
Just to be more precise, my intent here is to make an algorithm to make the program recognize the image and based on the pixel color it would draw a line with dots from the start to the end of the river, passing between it's middle.
To draw
UIBezierPath
onUIView
do this:This code will draw a dot with radius 8 with coordinates 10,20 on your view.
Here is an attempt at the lines part of the equation: