Using stretchable images in Xcode storyboards

前端 未结 5 1072
慢半拍i
慢半拍i 2020-12-22 21:02

I\'m using storyboards to layout my view controllers and I would like to use stretchable images for my buttons (so that I don\'t need to generate several images with differe

5条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-22 21:58

    It's doable in XCode's 5.0 Interface Builder with the assets catalog. Create an image asset ( if you don't already have an asset catalog you can create one as follows:

    1. File->New->File->Resources->Asset Catalog
    2. Then Editor->New Image Set
    3. Set the images for each Idiom & Scale
    4. Then hit the Show Slicing button to set the slices as you wish.

    Check Apple docs here: Developer Apple: Asset Catalog Help Then all you have to do is to set the background image of the button as the requested asset.

    EDIT: I've forgot to mention that it works as desired only in iOS7

提交回复
热议问题