答案 0 :(得分:0)
通过情节提要更改图像的切片时,它实际上会将更改应用于与图像相对应的Contents.json
文件。
应用对附件图像进行的更改,以下更改将应用于文件:
"resizing" : {
"mode" : "9-part",
"center" : {
"mode" : "tile",
"width" : 1,
"height" : 1
},
"cap-insets" : {
"bottom" : 27,
"top" : 26,
"right" : 21,
"left" : 21
}
}
您可以使用UIImage
方法resizableImage
通过编程方式应用相同的更改:
声明:
func resizableImage(withCapInsets capInsets: UIEdgeInsets, resizingMode: UIImage.ResizingMode) -> UIImage
用法示例:
let image = UIImage(named: "example.png")
let insets = UIEdgeInsets(top: 1, left: 2, bottom: 1, right: 2)
let imageWithInsets = image.resizableImage(withCapInsets: insets, resizingMode: .tile)