Giter Site home page Giter Site logo

sikandalex / uigradients-swift Goto Github PK

View Code? Open in Web Editor NEW
11.0 1.0 1.0 96 KB

Create a gradient in Swift/SwiftUI just by referring to its UIGradients name!

Swift 100.00%
swift gradients gradient uigradient uigradients ios-ui ios-swift ios swiftui color-gradient

uigradients-swift's Introduction

Made with love License

Quickly create gradients in Swift and SwiftUI by specifying a direction and gradient name!


ย 

Why use this library?

The great people over at UI Gradients have created some beautiful gradients. The problem is that to implement these gradients in your iOS project you have to:

  1. Copy the hex codes
  2. Convert the hex codes into UIColor/Color objects
  3. Add those colors to an array and use it to create a gradient

This library saves you time by allowing you to create these same gradients in Swift just by referring to their name on the site.

Installation with Swift Package Manager

File => Swift Packages => Add Package Dependency => https://github.com/SikandAlex/UIGradients-Swift.git

UIKit

Use 'master' branch

SwiftUI

Use 'SwiftUI' branch

Usage

Go to uigradients.com, find a gradient you love, and remember the name!

UIKit

import UIGradients_Swift

// Call addGradient on any UIView
self.view.addGradient(direction: .topToBottom, named: "Sunset")

SwiftUI

import UIGradients_Swift

// Create a gradient with the colors from https://uigradients.com/#Magic
Gradient(named: "Magic")

// Create a linear gradient background with the colors from https://uigradients.com/#PurpleParadise
.background(LinearGradient(gradient: Gradient(named: "Purple Paradise")!, startPoint: .top, endPoint: .bottom))

Available Directions

  • topToBottom
  • bottomToTop
  • leftToRight
  • rightToLeft
  • topLeftToBottomRight
  • topRightToBottomLeft
  • bottomLeftToTopRight
  • bottomRightToTopLeft

Python Script (used to scrape and convert the gradients from hex to UIColor/Color)

https://gist.github.com/SikandAlex/72f4891c534f98cdebd947ecb45aa915

Author and Acknowledgements

Created by Alex Sikand Find me on LinkedIn

Based on UIGradient by @dqhieu

uigradients-swift's People

Contributors

sikandalex avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

wiencheck

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.