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: Doug Hill <email@hidden>
- Date: Wed, 18 Jan 2017 12:43:23 -0800
Hello Eric,
There's a number of ways to approach this problem.
If you want to render this at runtime yourself, you'll need to learn Core Graphics and figure out how to create paths (e.g. arcs and lines). I'll have to leave it to a Google search or Apple docs for you to figure this out. It's actually pretty easy to do, so check your graphics context, coordinates, and the path, fill, and background colors.
Another approach is to render the individual frames of each state ahead of time and use those at runtime. For example, it there were only 10 positions on your knob you could render these positions separately in e.g. Photoshop and when the gesture recognizer sends an event that the user did a rotate gesture, you update an image view with a different pre rendered image.
There might also be a way to render one frame of the dial (e.g. the 'Ø' position) and apply a rotate transform. This is dependent on the design you have whether it could be rotated and still look good.
Good luck!
Doug Hill
> On Jan 18, 2017, at 12:34 PM, Eric E. Dolecki <email@hidden> wrote:
>
> [image: Screen Shot 2017-01-18 at 3.28.22 PM.png]
>
> I have been tasked to create a control. A giant knob that is ticked along
> its edge (the number dependent on the minimum & maximum values). Not 360
> degrees, just enough ticks to show the range. It will do other things as
> well, but I'm wondering how to approach this. The values will always be
> Int.
>
> I have included a screenshot. The longer dark tick will always show the
> current value. I didn't want to paste a lot of code in here, but I tried
> UIBezierPaths and my code only produced a black background. Would this be a
> ShapeLayer with another sublayer for the ticks? I'll be using
> UIGestureRecognizer to control the rotation of the "dial"...
>
> Eric
_______________________________________________
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