UIImage and resizableImageWithCapInsets Swift

扶醉桌前 提交于 2019-12-30 04:35:06

问题


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 resizableImageWithCapInsets with Swift). Please help me to use resizableImageWithCapInsets in Swift


回答1:


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)


来源:https://stackoverflow.com/questions/26255298/uiimage-and-resizableimagewithcapinsets-swift

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!