Merci de votre visite. Cette page est disponible en anglais uniquement.

Add a Login with Amazon Button to Your App

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 UIButton.

  1. Add a standard UIButton to 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.
  2. 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.
  3. 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.zip file. Find your preferred button in both the 1x and 2x directories and extract them from the zip. Extract the _Pressed version of your button if you want to show the button in a Selected state.
  4. Add the images to your project.
    1. In Xcode, with your project loaded, click File from the main menu and select Add Files to "project".
    2. In the dialog, select the button image file(s) you downloaded and click Add.
    3. The buttons should now be in the project under your project directory. Move them to the Supporting Files folder.
  5. Add the image to your button.
    To enable the image for your button, you can modify the button attribute or use the setImage:forState method on the UIButton object. Follow these steps to modify the image attribute for your button:
    1. Open the storyboard for your app.
    2. Select the button in your storyboard by clicking on it or selecting it from the View Controller Scene tree.
    3. In the Utilities window, open the Attributes Inspector.

      xcode button attributes
    4. At the top of the Attribute Inspector, set the Type of button to System.
    5. In the second group of settings, select Default for State Config.
    6. In the second group of settings, drop down the Image setting.
    7. Select the Login with Amazon button graphic you added to the project. Do not select the 2x version: it will be loaded automatically on high density display (Retina) devices.
    8. Set the same image for the Background setting.
    9. If you want to specify a pressed version of the button, select Selected for State Config, and set the Image to the _Pressed version of your button.
    10. On the storyboard, adjust the size of your button to accommodate the image, if necessary.