how to covert sketchApp style “linear-gradient(-45deg, #00CC51 7%, #00CC8F 100%);” to swift?


I found there was some difference between my code’s visual effect and designer’s preivew pictures. I wanted to know why?!


Find the reason of the difference, and then resolve it.


It was easy. Designers use sketchApp to draw ui. They must use some plugin to generate html code. Some the answer would be in the html source code.

Open index.html, plugin’s name is there — Sketch MeaXure.

 <title>Spec Export — Sketch MeaXure</title>

It was funny.And the answer was easy: sketchApp’s style had different zero degree standard!They have a diff of 90 degree.


Now, i can reproduce any skethApp’s linear-gradient, with linear-gradient.

CAGradientLayer().applySketch(angle: -45,
colors: [
(UIColor(hex6: 0x00CC51).cgColor, 0.07),
(UIColor(hex6: 0x00CC8F).cgColor, 1.0),

Related Information




iOS App Engineer

Love podcasts or audiobooks? Learn on the go with our new app.

Using the New PHPicker With SwiftUI

Screenshot of PHPicker

Firebase Authentication using iOS SDK

What Is the ReplaySubject in RxSwift?

Universal Links in

Swift UI Features!

Using Maps and Location Data in Your SwiftUI (+Realm) App

SwiftUI and Image/Audio files upload and download with CoreData

iOS 16: What We Could See!

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store


iOS App Engineer

More from Medium

Symbolicate a line from a raw crash log on iOS

Supporting Accessibility in your iOS app

Bees And Bomb Loading Animation Using SwiftUI

How to resolve the swiping right action when trying to navigate to a previous screen in iOS.