Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/uias/Randient
🎨 Radient, random gradients in Swift
https://github.com/uias/Randient
gradients ios swift ui
Last synced: 3 months ago
JSON representation
🎨 Radient, random gradients in Swift
- Host: GitHub
- URL: https://github.com/uias/Randient
- Owner: uias
- License: mit
- Archived: true
- Created: 2018-09-09T09:17:17.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2023-01-09T22:29:39.000Z (almost 2 years ago)
- Last Synced: 2024-07-09T00:58:21.582Z (4 months ago)
- Topics: gradients, ios, swift, ui
- Language: Swift
- Homepage: https://uigradients.com
- Size: 18.3 MB
- Stars: 72
- Watchers: 4
- Forks: 10
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
- awesome-gradient - Randient - 🎨 Radient, random gradients in Swift. (Swift)
README
## ⭐️ Features
- [x] Beautiful, automatically generated gradients from [uiGradients](https://uigradients.com) in Swift.
- [x] Smoothly animating, randomizable gradient views.
- [x] 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`:
```ruby
pod 'Randient'
```### Carthage
To install Randient using Carthage, add this line to your `Cartfile`:
```ruby
github "Randient"
```## 🚀 Usage
### Gradient Roulette
`RandientView` is a simple view that will display a randomly selected gradient from the [uiGradients](https://uigradients.com) catalog.```swift
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...
```swift
randientView.randomize(animated: true)
```### Those wonderful gradients
An enum of all the gradients from [uiGradients](https://uigradients.com) is generated every time that Randient is built.
These are available as an enum via `UIGradient`.
```swift
let gradient = UIGradient.royalBlue
let colors = gradient.data.colors
```If you're feeling lucky, a randomized `UIGradient` can also be retrieved.
```swift
let randomGradient = Randient.randomize()
```#### The raw stuff
Each `UIGradient` has associated `Data` which can be accessed via `.data`.
```swift
struct Data {
public let name: String
public let colors: [UIColor]
}
````Metadata` is also available, accessible via `.metadata`.
```swift
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
- Created by [Merrick Sapsford](https://github.com/msaps) ([@MerrickSapsford](https://twitter.com/MerrickSapsford))
- Heavily inspired by [UIColor-uiGradientsAdditions](https://github.com/kaiinui/UIColor-uiGradientsAdditions) by [kaiinui](https://github.com/kaiinui).## ❤️ Contributing
Bug reports and pull requests are welcome on GitHub at [https://github.com/uias/Randient](https://github.com/uias/Randient).## 👮🏻♂️ License
The library is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).