With all that being done, we can head back to storyboard and see everything in action! Changing button type and style in attributes inspectorĪt this point, if you create an IBAction and connect it to our custom button touch up inside event, you will notice that the action is not being triggered. Notice that we need to handle the initialisation failure for both type and style by falling back to their default value, this is because we have no control over the value being inputted from the storyboard attributes inspector. blackĪuthorizationButton = ASAuthorizationAppleIDButton(authorizationButtonType: type, Let style = (rawValue: authButtonStyle) ?. Next, we will update the draw(_:) method to initialise the ASAuthorizationAppleIDButton instance using authButtonType and authButtonStyle. Meanwhile, authButtonStyle will take ‘s raw value as its default value. authButtonType: Int = authButtonStyle: Int = Īs you can see, for code above, authButtonType will take the ‘s raw value as its default value. Here’s the updated MyAuthorizationAppleIDButton.swift.Īs a result, we can define variables of type Int and use to make them available in the storyboard attributes inspector. Next, go to the draw(_:) method and set cornerRadius as authorizationButton‘s corner radius. Note that we are using 6.0 as the default value of cornerRadius as that is the default corner radius of ASAuthorizationAppleIDButton. We just need to define a cornerRadius variable for MyAuthorizationAppleIDButton and tag it with cornerRadius: CGFloat = 6.0 The way to make corner radius available in the storyboard attributes inspector is quite straightforward. On top of that, we will also make all these 3 properties available for customisation in storyboard attributes inspector by using Create IBInspectable for Button Corner Radius In the next section, we will look into how to add these 3 properties into our custom button. ASAuthorizationAppleIDButton styling properties class MyAuthorizationAppleIDButton: UIButton Show Sign in with Apple button in storyboardĪfter successfully showing the Sign in with Apple button in storyboard, we can now work on customising the button’s appearance.īy looking into the Apple official documentation, you will find that there are 3 styling properties in ASAuthorizationAppleIDButton that we can utilise to change the appearance of the button. Next, implement all the required init methods so that the custom button can be used in storyboard. With all that being said, let’s go through the steps in detail one by one.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |