问题
I'm wanting to make a password unlock screen for my app, and I'm not sure how I'd go about it.
I'm wanting it to look like the Apple-designed version of it, which is the passcode lock setting screen.

How might I go about doing something like this, where as soon as all four digits are entered the code is immediately checked against a pre-set password?
Thanks!
回答1:
most likely you create the view and when all the fields are set you check against the known password or you check the hash of the input passkey against the hash you have stored.
basically you have a stored password/hash and you check against that when you have all field filled in in your view.
when the password is correct (either by hash checking or password) you show your next view, otherwise you display an error saying the password is incorrect.
回答2:
Just found a project that replicates this perfectly. I'm going to post this here for future reference in case anyone needs it. https://github.com/guicocoa/pinview

回答3:
Here is another library, just in case someone is looking for something like this: http://cocoacontrols.com/platforms/ios/controls/abpadlockscreen
回答4:
iOS 7 style Passcode. Complete functional demo with great documentation showing the different states (i.e Enable, Test, Change & Turn Off)
https://github.com/rolandleth/LTHPasscodeViewController
来源:https://stackoverflow.com/questions/4048894/making-a-password-lock-for-an-app