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: "Eric E. Dolecki" <email@hidden>
- Date: Wed, 18 Jan 2017 20:55:23 +0000
Yes - and best approach. The number of ticks will always be dynamic. I'm
making this control it's own UIView subclass. So when it's created, you
supply min value, max value, current value, etc.
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? Not sure, but I am creating
my path like this right now...
numberOfTics = 5 // I am actually getting this from the init, but it's here
for testing.
outerRadius = 210 // Same as above, here for testing.
innerRadius = 200 // Same as above.
path = UIBezierPath()
for i in 0..<numberOfTics {
let angle = CGFloat(i * 10) * CGFloat(2 * M_PI) / CGFloat(numberOfTics)
let inner = CGPoint(x: innerRadius * cos(angle), y: innerRadius *
sin(angle))
let outer = CGPoint(x: outerRadius * cos(angle), y: outerRadius *
sin(angle))
print(angle)
path.move(to: inner)
path.addLine(to: outer)
}
I can't actually see this path yet to know if it's generating anything
useful. I haven't done anything with CoreGraphics really like this. If I
can get the ticks on a "dial" I think I can figure out the rest.
On Wed, Jan 18, 2017 at 3:41 PM Jens Alfke <email@hidden> wrote:
> I’m not sure what you’re asking. This is just a circle and a couple of
> lines, with some basic trig to compute the endpoints of the lines. Are you
> asking how to use the CG graphics APIs?
>
> —Jens
_______________________________________________
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