什么是 SketchTool
SketchTool是一个与Sketch捆绑的 命令行实用工具 ,它允许您使用Sketch文档执行一些操作,比如检查或导出资源。它还允许您从命令行控制Sketch来执行一些操作。
安装SketchTool
下载Sketch,解压 Sketch 获取 Sketch.app;把 Sketch.app 拖到 Applications(应用程序)中。
安装完 Sketch.app 你就可以在 Sketch.app/Contents/Resources/sketchtool/bin
目录下找到sketchtool
导出PNG Shell 命令
#!/bin/bash
export PATH=$PATH:/Applications/Sketch.app/Contents/Resources/sketchtool/bin
#echo $PATH
#sketchtool help
sketchtool export artboards inputFilePath --output=DirPath --formats="png"
在Xocode中导出
# AppIcon
export PATH=$PATH:/Applications/Sketch.app/Contents/Resources/sketchtool/bin
sketchtool export artboards "$PROJECT_DIR"/"Graphics Resources/AppIcon.sketch" --output="$PROJECT_DIR"/"$PROJECT_NAME"/Images.xcassets/AppIcon.appiconset --formats="png"
# LaunchImage
sketchtool export artboards "$PROJECT_DIR"/"Graphics Resources/LaunchImage.sketch" --output="$PROJECT_DIR"/"$PROJECT_NAME"/Images.xcassets/LaunchImage.launchimage --formats="png"
网友评论