Re: Swift: Draw a circle with tic marks at it's edge?
Re: Swift: Draw a circle with tic marks at it's edge?
- Subject: Re: Swift: Draw a circle with tic marks at it's edge?
- From: Quincey Morris <email@hidden>
- Date: Wed, 18 Jan 2017 13:35:46 -0800
- Feedback-id: 167118m:167118agrif8a:167118sXW6Sbw1j9:SMTPCORP
On Jan 18, 2017, at 12:55 , Eric E. Dolecki <email@hidden> wrote:
>
> When one swipes, it will rotate the control and change the value. I'm just
> trying to get the drawing correct. Should the dial be a UIView with its
> layer cornerRadius set so it's round, and then create a shape layer with my
> path and then add that to the dial's sublayer?
You’re trying to address a number of separate issues promiscuously, and that’s making a fairly straightforward task seem harder.
— You need a custom UIView, and normally that’s going to be rectangular. (The shape of the UIView itself is only an issue if hit testing is an issue.)
— You draw the view’s contents in its “draw(_:)” or “-[drawRect:]” method, according to the language.
— In your draw method, you construct a UIBezier path, and then stroke that path to make it visible. In your example code, you wouldn't want to fill the path.
— You need to add any needed behavior for touching or manipulating the view, when appropriate. This might be done with gesture recognizers, or by overriding the “touchesBegan” family of UIResponder methods.
That’s it.
Everything else you might do (non-rectangular view, using CoreAnimation, etc) is a refinement you can come back to, if you’re not satisfied by the way the simplistic view appears or behaves.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden