Add a Login with Amazon Button to Your App
LWA for iOS
Login with Amazon provides several standard buttons you can use to prompt users to login from your app. This section gives steps for downloading an official Login with Amazon image and pairing it with an iOS
- Add a standard
UIButtonto your app.
For a tutorial on how to add a button to an app, see Creating and Configuring View Objects and Start Developing iOS Apps Today on developer.apple.com.
- Add the Touch Up Inside event for the button to a method named
onLoginButtonClicked. Leave the implementation blank for now. The Creating and Configuring View Objects and Start Developing iOS Apps Today on developer.apple.com tutorial includes steps on adding a button event.
- Choose a button image.
Consult our Login with Amazon Style Guidelines for a list of buttons you can use in your app. From there, you can download a copy of the
LWA_for_iOS.zipfile. Find your preferred button in both the
2xdirectories and extract them from the zip. Extract the
_Pressedversion of your button if you want to show the button in a Selected state.
- Add the images to your project.
- In Xcode, with your project loaded, click File from the main menu and select Add Files to "project".
- In the dialog, select the button image file(s) you downloaded and click Add.
- The buttons should now be in the project under your project directory. Move them to the
- Add the image to your button.
To enable the image for your button, you can modify the button attribute or use the
setImage:forStatemethod on the
UIButtonobject. Follow these steps to modify the image attribute for your button:
- Open the storyboard for your app.
- Select the button in your storyboard by clicking on it or selecting it from the View Controller Scene tree.
In the Utilities window, open the Attributes Inspector.
- At the top of the Attribute Inspector, set the Type of button to System.
- In the second group of settings, select Default for State Config.
- In the second group of settings, drop down the Image setting.
- Select the Login with Amazon button graphic you added to the project. Do not select the
2xversion: it will be loaded automatically on high density display (Retina) devices.
- Set the same image for the Background setting.
- If you want to specify a pressed version of the button, select Selected for State Config, and set the Image to the
_Pressedversion of your button.
- On the storyboard, adjust the size of your button to accommodate the image, if necessary.