# SketchToSwift
![Demo](https://raw.githubusercontent.com/s4cha/SketchToSwift/master/demo.gif)
![Language: Javascript](https://img.shields.io/badge/language-javascript-f48041.svg?style=flat)
[![License: MIT](http://img.shields.io/badge/license-MIT-lightgrey.svg?style=flat)](https://github.com/s4cha/SketchToSwift/blob/master/LICENSE)
[![Release version](https://img.shields.io/badge/release-0.1-blue.svg)]()
## Why
Because **integrating views** form Sketch has **no added value**, its just back and forth translating sketch values to swift code. There must be a way to automate this time costly and low added value labor.
## How
By **generating the swift UIKit code** from a Sketch Artboard. We can save hours of time \o/
## What
A **Sketch plugin** with a simple shortcut that generates basic Swift code form wich you can kickstart developing your view.
## About
This is a proof of concept that we can generate UIVIew swift code from Sketch Artboards.
Be aware that this is very early in development.
Yes this will never be perfect (huh wait for AI!), because we all have our coding styles etc. But this is not the goal anyway, the goal is to kickstart view dev and save 80% of integration time. Then you are free to change the code as you like :)
## Usage
- Install (double click) plugin
- Select Artboard
- `cmd` + `alt` + `K` for UIKit code
- `cmd` + `alt` + `L` for [Stevia](https://github.com/s4cha/Stevia) code
- Paste swift Uikit UIView subclass in Xcode \o/
## Get the best out of it
Here are some rules you can follow to get the best export possible :
- Name your Artboard proprely:
For instance an Artboard named "Profile" will generate `class ProfileView: UIView `
- Resize Artboard for your iPhone size (ex: we usually use 375Width for iPhone 7)
By resizing the artboard with the scale tool, you'll make sure the script will generate the good font sizes etc.
- Name your sketch layers right in order to get sexy variable names
- After the scale, you probably have float margins and font size. Making sure these are clean ext 16p instead of 16,01543 will generate cleaner code :)
- The same Applies to margins and sizes in general
- Flatten the view hierarchy, extract the items inside groups and bring them to the top level.
- Order them (usually from the to to the bottom), the generated code will keep the view hierarchy order.
## Improvements
#### Fonts
- Find a way to export fonts ?
#### Text
- Detect Text in style caps -> apply uppercased
- Detect character spacing in fonts -> AttributedString
- Detech line spacing -> AttributedString
- Detect Multiline (contains \n) -> Append \n and set label to mutiline
- Detect text alignment all cases
- Multicolor -> Generate AttributedString
#### Colors
- UIColors replace by custom ones?
- UIColors oftenThe same refactor in one variable
#### Radius
- Detect UIButton corner Radius
#### Borders
- Button border color
- Button border radius
#### Sketch Groups
- groups -> greate UIViewSubclasses?
- UIButton set title belongs in content section
#### layout
- Detect fillscontainer and do not use width and height but right and bottom laike a human would do
- Implement relative layout, like more visually to the right -> align on right rather tahn left , more natural
#### Export
- Handle single Element Export
#### UITableViewCell
- Artboard name Suffixed by `Cell` -> UITableViewCell subclass
#### Images
- Find a wa to detect images and create UIImageView instead
#### Groups
- Think about how to handle them proprely
## Known issues
This plugin only supports Sketch v41 and higher at the moment.
## Issues
Have a layout that breaks the plugin?
Send it to sachadso@gmail.com for review + open Issue
## Author
Sacha Durand Saint Omer, sachadso@gmail.com
## Contributing
Contributions to SketchToSwift are very welcomed and encouraged! Feel free to try and tackle one of the Improvements above
## License
SketchToSwift is available under the MIT license. See [LICENSE](https://github.com/s4cha/SketchToSwift/blob/master/LICENSE) for more information.
没有合适的资源?快使用搜索试试~ 我知道了~
SketchToSwift:Sketch从Sketch生成Swift
共9个文件
md:3个
js:2个
sketch:1个
5星 · 超过95%的资源 需积分: 15 2 下载量 166 浏览量
2021-02-06
11:25:45
上传
评论
收藏 1.74MB ZIP 举报
温馨提示
SketchToSwift 为什么 由于从Sketch集成视图形式没有附加值,因此仅将草图值前后转换为快速代码即可。 必须有一种方法可以使这段时间的成本高昂且附加值低的劳动力自动化。 怎么样 通过从素描画板生成快速的UIKit代码。 我们可以节省数小时的时间\ o / 什么 一个带有简单快捷方式的Sketch插件,可以生成基本的Swift代码形式,您可以开始开发视图。 关于 这是一个概念证明,我们可以从Sketch Artboards生成UIVIew快速代码。 请注意,这还处于开发初期。 是的,因为我们所有人都有自己的编码风格等,所以这将永远是不完美的(呵呵,等一下!)。但这毕竟不是目标,目
资源详情
资源评论
资源推荐
收起资源包目录
SketchToSwift-master.zip (9个子文件)
SketchToSwift-master
example.sketch 56KB
CODE_OF_CONDUCT.md 3KB
LICENSE 1KB
README.md 4KB
demo.gif 1.82MB
Rules.md 317B
UIKitExport.sketchplugin
Contents
Sketch
UIKitExport.js 13KB
SteviaExport.js 11KB
manifest.json 742B
共 9 条
- 1
吃肥皂吐泡沫
- 粉丝: 33
- 资源: 4587
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论1