Code Monkey home page Code Monkey logo

randient's Introduction

Tabman

CocoaPods Platforms

Tabman

โญ๏ธ Features

  • Beautiful, automatically generated gradients from uiGradients in Swift.
  • Smoothly animating, randomizable gradient views.
  • Life is like a box of chocolates.

๐Ÿ“‹ Requirements

iOS 9 & Swift 4 / 5.

๐Ÿ“ฒ Installation

CocoaPods

To install Randient using CocoaPods, add this line to your Podfile:

pod 'Randient'

Carthage

To install Randient using Carthage, add this line to your Cartfile:

github "Randient"

๐Ÿš€ Usage

Gradient Roulette

RandientView is a simple view that will display a randomly selected gradient from the uiGradients catalog.

let randientView = RandientView()
randientView.frame = CGRect(x: 0, y: 0, width: 100, height: 100)
view.addSubview(randientView)

Updating to a new gradient is as simple as...

randientView.randomize(animated: true)

Those wonderful gradients

An enum of all the gradients from uiGradients is generated every time that Randient is built.

These are available as an enum via UIGradient.

let gradient = UIGradient.royalBlue
let colors = gradient.data.colors

If you're feeling lucky, a randomized UIGradient can also be retrieved.

let randomGradient = Randient.randomize()

The raw stuff

Each UIGradient has associated Data which can be accessed via .data.

struct Data {
    public let name: String
    public let colors: [UIColor]
}

Metadata is also available, accessible via .metadata.

struct Metadata {
    public let isPredominantlyLight: Bool
}

Gradient View

RandientView inherits from GradientView, which under the hood uses simply uses a CAGradientLayer for rendering gradients.

GradientView provides the following:

  • .colors: [UIColor]? - Colors of the gradient.
  • .locations: [Double]? - Locations of each gradient stop.
  • .startPoint: CGPoint - Start point of the gradient (Defaults to 0.5, 0.0).
  • .endPoint: CGPoint - End point of the gradient (Defaults to 0.5, 1.0).

๐Ÿ‘จ๐Ÿปโ€๐Ÿ’ป About

โค๏ธ Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/uias/Randient.

๐Ÿ‘ฎ๐Ÿปโ€โ™‚๏ธ License

The library is available as open source under the terms of the MIT License.

randient's People

Contributors

msaps avatar

Watchers

 avatar  avatar

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.