Shiny is an iOS library that generates an iridescent effect view matched to the gyroscope similar to the Apple Pay Cash card in the Wallet app.
$ pod try Shiny
- iOS 9.0+
- Xcode 9.0+
- Swift 4
Adding ShinyView
programmatically (supports storyboard/xib too):
import Shiny
let shinyView = ShinyView(frame: CGRect(x: 0, y: 0, width: 320, height: 200))
shinyView.colors = [UIColor.red, UIColor.green, UIColor.blue, UIColor.gray]
shinyView.locations = [0, 0.1, 0.2, 0.3, 1]
shinyView.startUpdates() // necessary
view.addSubview(shinyView)
You must call startUpdates()
for the instance to observe motion changes. Calling stopUpdates()
on the instance will stop motion updates.
The ShinyView
exposes several properties to customize the radial gradient used to create the shiny effect:
var colors: [UIColor] // The color of each gradient stop.
var locations: [CGFloat]? // The location of each gradient stop. The default is `nil`.
var spread: CGFloat // The distance between colors on the gradient. The default is `0.8`.
var padding: CGFloat // The padding on the edges of the gradient. The default is `0.1`.
var sensitivity: CGFloat // The sensitivity of the gyroscopic motion. The default is `0.2`.
You can start/stop observing motion updates:
func startUpdates() // Starts listening to motion updates.
func stopUpdates() // Stops listening to motion updates.
Shiny is available via CocoaPods and Carthage.
To install with CocoaPods, simply add this in your Podfile
:
use_frameworks!
pod "Shiny"
To install with Carthage, simply add this in your Cartfile
:
github "efremidze/Shiny"
- If you found a bug, open an issue.
- If you have a feature request, open an issue.
- If you want to contribute, submit a pull request.
Feel free to submit a PR if you’re using this library in your apps.
Shiny is available under the MIT license. See the LICENSE file for more info.