Change its text to “Authentication Result” and its font to the “Headline” style. Open up its size inspector and change the following values to: Double click it and change its text to “Authenticate”. Now, drag a button onto the view controller. In the attributes inspector, change the title to “Touch ID Demo”:įrom here on, we will just be dealing with the root view controller for the user interface. Next, click on the “Navigation Item” of the root view controller in the document outline. Your navigation controller should have the black arrow pointing to it like this: To change it, click the navigation controller, open up the attributes inspector, and check “Is Initial View Controller”: Last, be sure the starting point is set to our newly added navigation controller. Next, control + drag the navigation controller to the default view controller and let go. We just want to work with a blank canvas for our user interface. By default, Xcode gives us a table view controller as the root view controller. Now, select the root view controller in the document inspector and press the delete key. Place it right underneath the existing view controller. In the object inspector, drag out a “Navigation Controller” and drop it into the storyboard. This flowchart summarizes the entire work flow:įirst we’ll embed the included view controller into a navigation controller. You can look at the error’s code property to see the exact LAError value set. It’s property called localizedDescription will also be set, representing one of the values found inside LAError. If the authentication context doesn’t allow for multiple attempts, than an NSError object will be initialized. For instance, this would occur if a fingerprint couldn’t be read correctly and the “Try Again” message appeared. If authentication didn’t pass, iOS first evaluates if another attempt can take place. I’ll show you an example of this shortly. No matter the outcome, the closure that’s provided will execute. Next, the actual authentication takes place. This preflights authentication for efficiency purposes, as there is no reason to continue any further if the system has no chance of successful authentication. After that, we then ask iOS if that policy can be evaluated. The first thing we will need to do is choose a policy to authenticate against. Now that we know which framework and object to use, let’s discuss the authentication workflow. TouchIDNotEnrolled: User hasn’t set up Touch ID.TouchIDNotAvailable: Device doesn’t support Touch ID.PasscodeNotSet: User hasn’t set up a system wide 4 digit passcode.SystemCancel: iOS canceled authentication.UserFallback: User chose fallback method, i.e.UserCancel: User canceled authentication.AuthenticationFailed: Invalid credentials.When the authentication process encounters a problem, it will be one of the errors represented inside LAError. There is one other important enumeration to know about on LAContext, and that is LAError. Keeping this lone value in an enumeration keeps it scalable, so perhaps Apple will use this for future types of local authentication in addition to Touch ID. The supported types of authentication are housed inside the LAPolicy enumeration, which contains only one value – DeviceOwnerAuthenticationWithBiometrics. That’s it.LAContext serves as a way to carry out any type of authentication that can be performed by its parent framework. When the tap ends, the value of isRecording is animated from 0.0 -> 1.0 or 1.0 to 0.0 depending on the state of the button. When the button is tapped, isPressed is set to true until the tap ends. isRecording, a fraction (0.0->1.0) controls the transition of the inner circle from a circle to a smaller rounded square.isPressed, a boolean, controls the color used to draw the inner circle.Using PaintCode’s expressions I have two parameters: The outer circle is the button’s frame (white), and the inner circle is the tappable button (red). I have a square canvas in which there are two concentric circles. PaintCode makes creating simple designs like this very simple. I wanted to create a record/stop button for a project I’m working on that mirrored the appearance of the record/stop button found in Apple’s iOS Camera Video recorder and Voice Recorder applications. The code for this project is available on GitHub. Here is an example of how to use PaintCode to create an animated button.
0 Comments
Leave a Reply. |