Search code examples
swiftios8storyboardtabbar

How to add @2x, @3x sizes images for a tab bar icon in storyboard


I can't add multiple images with different size for a tab bar icon in storyboard. How can i do this ?


Solution

  • Your images with the different sizes should be named as followed :

    Then you can add those three images into your image.xcassets, Xcode will sort them automatically.

    In interface builder finally you can select your image in your tab bar item by selectring imageName. The program will choose the right size automatically.

    Programmatically you can choose your image with :

    UIImage(named: "imageName")
    

    The right size will also automatically be chosen