Rye allows you to present non intrusive alerts to your users of both "Toast" and "Snack Bar" types.
You can choose to display the default Rye alert type or go fully custom and display your own UIView
.
Custom Rye with Image | Custom Rye with Button | Default Rye |
iOS 11.4 Swift 5
github "nodes-ios/Rye"
pod 'nodes-ios/Rye'
import Rye
let ryeConfiguration: RyeConfiguration = [Rye.Configuration.Key.text: "Message for the user"]
let rye = RyeViewController.init(alertType: .toast,
viewType: .standard(configuration: ryeConfiguration),
at: .bottom(inset: 16),
timeAlive: 2)
rye.show()
let ryeConfiguration: RyeConfiguration = [
Rye.Configuration.Key.text: "Error message for the user",
Rye.Configuration.Key.backgroundColor: UIColor.red.withAlphaComponent(0.4),
Rye.Configuration.Key.animationType: Rye.AnimationType.fadeInOut]
]
let rye = RyeViewController.init(alertType: .toast,
viewType: .standard(configuration: ryeConfiguration),
at: .bottom(inset: 16),
timeAlive: 2)
rye.show()
let customRyeView = RyeView()
let rye = RyeViewController.init(alertType: .toast,
viewType: .custom(customRyeView),
at: .bottom(inset: 16),
timeAlive: 2)
rye.show()
Rye allows you to define the alert type you want to display to your user. Possible alert types are:
- snackBar which is displayed at applications UIWindow level and allows interaction with the presented UIView
- toast which is displayed at applications alert UIWindow level and doesn't allows interaction with the presented UIView
With Rye you can specify the position where the Rye view will be displayed on screen via the position
parameter, which takes an associated value that allows you to specify the inset.
By default Rye will calculate the safe area insets for you, so be sure to specify only the extra desired inset.
If you decide to not provide a value for this parameter, you will be in charge of dismissing the Rye when you think it is appropriate.
When creating an instance of RyeViewController
you can choose to provide a value for the timeAlive
parameter during initialisation. The value provided will be the time in seconds the Rye view will be presented on screen to the user.
The following keys can be used in the configuration dictionary when presenting a default type Rye:
.backgroundColor (must be a UIColor)
.textColor (must be a UIColor)
.textFont (must be a UIFont)
.text (must be a String)
.cornerRadius (must be a CGFloat)
.animationType (must be a Rye.AnimationType)
.animationDuration (must be a TimeInterval)
If configuration is set to nil, a default configuration will be used. Any options set, will override the default state.
To learn more, please refer to the example project contained in this repository.
Made with ❤️ at Nodes.
Rye is available under the MIT license. See the LICENSE file for more info.