Sometimes you might want to create a Circle out of a UIView or want to create an static Circle on the view or subview or on a map which always stays at the center because there is no way you can keep the provided Circle class (Google Maps) of a map always at the center.

Let’s see how to do that.

Create a new project and drag a Slider on the controller, create it’s action of type UISlider and set its Minimum and Maximum value to 30 and 200 respectively(or whatever you like).

Create two variables

and write the following function in your ViewController.

After that in your viewDidLoad() call your function.

After that in your Slider Action

 

The circle grows in x and y dimensions downwards when the slider is increased. The only reason half of the current value of the slider was subtracted from the center of both x and y was to make the circle grow in size from the center.

At last run and test your code, following result will be achieved.

Download its source from Github.
Cheers!

Share:

administrator

1 Comment

Leave a Reply

Your email address will not be published. Required fields are marked *