Using stretchable images in Xcode storyboards

前端 未结 5 1076
慢半拍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:55

    With Xcode 6 (and iOS7+ target) you can use slicing editor when working with images assets. Toggle slicing mode with Editor -> Show Slicing menu or press Show Slicing button when select specific image with editor (showed below).

    Show Slicing button

    Then you can select image for specific display scale and drag rules or edit insets values manually.

    Rules

    After that you can select this image in Interface Builder. For example I use it for UIButton Background Image (IB button's representation could look bad, but it should be OK when running).

    My buttons look well (running iOS 7.1 simulator and iOS 8 device).

    enter image description here

    This Apple doc link could be helpful.

提交回复
热议问题