你看过关于新版本的草图吗?
https://github.com/abynim/Sketch-Headers
如果您想构建一个支持所有版本的插件,您可以更改您的代码:
首先,您需要将您的草图版本作为变量捕获。
function getSketchVersionNumber() {
const version = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleShortVersionString"]
var versionNumber = version.stringByReplacingOccurrencesOfString_withString(".", "") + ""
while(versionNumber.length != 3) {
versionNumber += "0"
}
return parseInt(versionNumber)
}
var sketchVersion = getSketchVersionNumber()
fill.setFillType(4)
if (sketchVersion > 370) {
// you need to grab the image with MSImageData like this one
var image = [[MSImageData alloc] initWithImage: imageData convertColorSpace: false]]
fill.setImage(image)
} else if(sketchVersion < 350) {
[fill setPatternImage:imageData collection:[[fill documentData] images]]
} else {
fill.setPatternImage(imageData)
}
fill.setPatternFillType(1)