Monday, April 20, 2015

Adding a New Image Button to an iOS Program

In iOS, a button can be represented by an image. Here’s how to add a new image to your Xcode project.


  1. In images.xcassets, add a new image set (right-click and choose New Image Set).
  2. Drag your images to the image set. Consider having different sizes for different purposes (retina screens vs older screens, and so forth).
  3. In Attribute Manager, view the object library and drug a button to the storyboard.
  4. Set the desired image to be the new graphic for the button (you must have the Assistant Editor selected and click on the Attributes Inspector in order to do this).
  5. On the storyboard, Ctrl-drag to create an action for the new button.
  6. Put code in the button’s new action.


No comments:

Post a Comment