简体   繁体   English

我们可以在 Xcode 中直接使用 Sketch UI 元素吗?

[英]Can we use sketch UI elements directly into Xcode?

I am new to sketch 3. I have a hand on experience with Xcode and iOS development.我是 Sketch 3 的新手。我有 Xcode 和 iOS 开发方面的经验。

My question is wether we can directly use sketch elements in xcode or sketch is only used for prototyping the UI?我的问题是我们可以直接在 xcode 中使用草图元素还是草图仅用于 UI 原型设计?

For example, If I design Label with a text field in sketch then can I used it as UI Label and UITextField in Xcode?例如,如果我在草图中设计带有文本字段的标签,那么我可以将它用作 Xcode 中的 UI 标签和 UITextField 吗?

In my experience as a designer that also develops in Xcode any solutions that claim to go directly from Sketch into Xcode either become vapourware after some time or don't provide a very good solution.根据我作为一名也在 Xcode 中开发的设计师的经验,任何声称可以直接从 Sketch 进入 Xcode 的解决方案要么在一段时间后变成蒸汽软件,要么没有提供很好的解决方案。 I assume it's because Auto Layout is quite complicated and fragile.我认为这是因为自动布局非常复杂和脆弱。

It's best to just learn iOS development using Storyboards or possibly SwiftUI for layout.最好只学习使用 Storyboards 或 SwiftUI 进行布局的 iOS 开发。 There are some elements that you can get from Sketch into Xcode such as colors, typography and iconography.您可以从 Sketch 中获取一些元素到 Xcode 中,例如颜色、排版和图标。

Here's a list of apps that can help you with that:以下是可以帮助您解决此问题的应用程序列表:

Typically speaking, you only use Sketch for prototyping the UI. 通常来说,您仅使用Sketch制作UI原型。 However, I'm much more of a developer than a designer. 但是,我更多是开发人员,而不是设计师。 So when I ended up needing to turn all of my artboards into UIKit code, I thought AUTOMATION! 因此,当我最终需要将所有画板都转换为UIKit代码时,我想到了AUTOMATION! But no one had made a plugin to do that. 但是没有人制作一个插件可以做到这一点。 So I did. 所以我做了。

I created a Sketch Plugin ( http://sketchcodeflow.com ) that does just this. 我创建了一个素描插件( http://sketchcodeflow.com )来完成此任务。 It transforms artboards into Objective-C UIKit and SpriteKit code. 它将画板转换为Objective-C UIKit和SpriteKit代码。 Even exports into asset catalogs for @1-3x. 甚至可以导出到@ 1-3x的资产目录中。 Simply #import and write one line of code in your ViewController and you got your app running. 只需#import并在ViewController中编写一行代码,即可运行您的应用程序。 Of course, that's UI only. 当然,那只是UI。 You'll have to write all logic yourself though there are a few features to help improve your experience such as animations and parallax. 尽管有一些功能可以帮助改善您的体验,例如动画和视差,但是您必须自己编写所有逻辑。

As far as designing a Label and hoping it turns into a UILabel, unfortunately that's not supported yet. 就设计Label并希望将其变成UILabel而言,不幸的是尚不支持。 For now, you can only export the image of it as a png, which will be populated by a UIImageView or a UIButton. 目前,您只能将其图像导出为png,将由UIImageView或UIButton填充。

没有办法在xcode中集成sketch元素,可以使用可以购买的sketch插件: https : //www.paintcodeapp.com/sketch

I had the same problem, the design was already prepared in the Sketch and wanted to get the code from it easily.我遇到了同样的问题,设计已经在 Sketch 中准备好了,想从中轻松获取代码。 My friends and I've working on a solution for converting design into UI codes, last 2 years.我和我的朋友们在过去 2 年里一直致力于将设计转换为 UI 代码的解决方案。

We've developed Monday Hero platform to improve the development phase and actually save time for repetitive code.我们开发了Monday Hero平台来改进开发阶段并实际上节省重复代码的时间。 https://www.mondayhero.io https://www.mondayhero.io

In Monday Hero, you can upload design and get responsive code with Storyboard, Xib or only code options.在 Monday Hero 中,您可以使用 Storyboard、Xib 或仅代码选项上传设计并获取响应式代码。 You can also select the elements on the design, group them as you wish for your code library and download it easily in like 15 minutes :) It was a dream of me to get the UI code that easily, I hope it can be also useful to you.您还可以选择设计上的元素,根据需要将它们分组到您的代码库中,然后在 15 分钟内轻松下载:) 轻松获得 UI 代码是我的梦想,我希望它也能有用给你。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM