Re: Swift: Draw a circle with tic marks at it's edge?

2017-01-18 Thread 2551phil

> On 19 Jan 2017, at 03:34, Eric E. Dolecki  wrote:
> 
> I tried
> UIBezierPaths and my code only produced a black background

“There’s an app for that” - have a look at PaintCode. 

https://www.paintcodeapp.com



Best


Phil
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Swift: Draw a circle with tic marks at it's edge?

2017-01-18 Thread Quincey Morris
On Jan 18, 2017, at 12:55 , Eric E. Dolecki  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 (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Swift: Draw a circle with tic marks at it's edge?

2017-01-18 Thread Eric E. Dolecki
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.. 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 (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Swift: Draw a circle with tic marks at it's edge?

2017-01-18 Thread Doug Hill
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  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 (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Swift: Draw a circle with tic marks at it's edge?

2017-01-18 Thread Jens Alfke
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 (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Swift: Draw a circle with tic marks at it's edge?

2017-01-18 Thread Eric E. Dolecki
[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 (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Weird NSPredicate structure when using "first" in keypath

2017-01-18 Thread Jens Alfke

> On Jan 17, 2017, at 7:18 PM, Chris Hanson  wrote:
> 
> Then if your users want to use a predicate string (rather than an 
> NSPredicateEditor or other form of direct instantiation) they still trivially 
> can, but it's on them to get the syntax correct rather than on you to try to 
> figure out their intent.

Because then if they don’t get the syntax correct, they’ll ask for help in our 
support forums, and it’s on us to answer the same question over and over again.
Or they’ll just decide our library doesn’t work and give up on it.

(I do see this as a design defect in the NSPredicate parser. The fact that the 
identifiers ‘first’ and ‘last’ have special meaning as array subscripts should 
not prevent them from being used as ordinary property names in key-paths.)

—Jens
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com