Boris-Em/BEMAnalogClock

The hands don't change size according to auto layout constraints like the clock itself does

Closed this issue · 9 comments

When I put the clock on the storyboard and added some constraints to make the clock fill the screen when the screen is larger, this happens (iPad Pro):

simulator screen shot 28 oct 2016 8 00 13 am

As you can see, the clock itself indeed resized, but the hands stay small. I know this is due to using a constant number as the length of the hands. Are there any workarounds to make the hands resize according to autolayout constraints? Maybe you can make properties like hourHandLengthPercentage so that people can set the length as a percentage of the radius? So if I set this property to 0.5 then the hour hand's length is half the radius?

You can update the hands' length in layoutSubviews. It would really be better to have a relative hand size, though.

Can you do a PR or something? I'm not very familiar with Objective-C...

@Sweeper777 I mean you can correct your layout from code in a layoutSubviews method. That's not a universal solution.

Yes, I understand. Will the pod support relative lengths in the future?

I'm not aware of such plans. The proposal seems to be rational, so the corresponding PR (being of an appropriate quality) has good chances to be merged.

I see. Also, how can I get the radius of the clock? I tried hubRadius but the value returned by it seems a lot smaller than the apparent radius.

I presume you're talking about clock.bounds.width / 2 (assuming it's square).

Ah! Haven't thought about that, thanks!

Hi @werediver & @Sweeper777.
There is currently no ongoing effort to support relative hand size that I'm aware of. It would indeed make way more sense than to set the size of the hands "manually".
Please let me know if one of you would like to work on such feature.
Thanks!