I want to create circular menu like below for iPhone app.
I searched many libraries or solutions, however was unable to find the same. What all have is when they click on icon, menu action is called, however I want to call action if I click anywhere on the button as shown below.
User action will only get called if I click anywhere in the user of user as shown in above image.
Any idea how to achieve this?
I have one idea as checking the x & y position of the tap and findout where its clicked (but this is very time costly)
OR
Is there any way to create buttons of these shapes?
That's actually a very good idea, and the calculations are not very costly at all.
Notes:
I flipped the
dy
calculation because the coordinate system is upside down. This just returns the coordinate system to the+y
is up mathematical sense and changes the final ordering of0
through7
.If you wanted, you could modify this to return an
Int?
and then returnnil
for touches that aren't on a button.