UIImage and resizableImageWithCapInsets Swift

前端 未结 1 1867
轮回少年
轮回少年 2021-01-02 09:28

I\'m newer with Swift\'s Apple. I had read an article from Here

But don\'t know how to do something like that(or just simple don\'t know how to use resizableIm

相关标签:
1条回答
  • 2021-01-02 09:39

    Generic way in Xcode 6.1 is:

    1. Create an UIImage as a variable
    2. Create an insets
    3. Create a new image based on the original image and the insets, and assign it to the original image

    var myImage = UIImage(named: "navbar.png")!
    let myInsets : UIEdgeInsets = UIEdgeInsetsMake(13, 37, 13, 37)
    myImage = myImage.resizableImageWithCapInsets(myInsets)
    
    0 讨论(0)
提交回复
热议问题