TimOliver / TOPasscodeViewController

A modal passcode input and validation view controller for iOS
MIT License
385 stars 96 forks source link

fix origin x of TOPasscodeButtonLabel's label. #1

Closed RyoAbe closed 6 years ago

RyoAbe commented 6 years ago

numberLabel and letteringLabel was just a little out of position.

before

before

after

after

diff

diff
TimOliver commented 6 years ago

Hey @RyoAbe! Thanks for the PR.

Hmm. Centering the text and making the label view widths the same as the button view is certainly one way to get more granular control, but I feel like that might also be incurring a performance hit.

I chose to use [UILabel sizeToFit] to make sure the labels were only as big as they needed to be. When they're bigger than that, Core Animation needs to do more blending passes with the extra pixels in the bigger label, which means slower performance (And this view controller is already pretty heavy).

Here's an example of what I mean:

simulator screen shot - iphone se - 2017-08-19 at 20 40 49

The red should only encompass where the text is being drawn, but it accounts for the whole label bounds.

The reason the labels are probably off-center is because CGRectIntegral rounds decimal numbers to whole numbers, which means it's not taking advantage of the Retina display.

It might be more appropriate to replace CGRectIntegral with something that can handle 2x on Retina and 3x on Retina HD. :)

What do you think?