Temporary and unobtrusive translucent alert view for iOS.
HumbleAlertView allows you to present a translucent alert view with a title and an optional message on the bottom of the screen. Use it to inform your user about temporary issues that do not require any immediate action and are not blocking the flow of your app.
HumbleAlertView can have a title and an optional message, in a way similar to UIAlertView. It automatically fades out after a configurable time interval and, by default, can be dismissed with a tap. It can automatically adapt its size according to the device it's being deployed on, user interface orientation and length of the strings passed to it.
To run the example project, clone the repo, and run pod install
from the Demo directory first.
HumbleAlertView is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod "HumbleAlertView"
HumbleAlertView requires that you include the QuartzCore.framework in your project.
After that, here's how you present an HumbleAlertView:
let humble = HumbleAlertView(title: "Hi there.", message: nil, timeout: 5.0, dismissible: false)
humble.show()
Just like with UIAlertView, the dismissal of the view is handled by the view itself, so there's no need to call anything else. If you do want to dismiss it manually, just call hide
on the instance.
HumbleAlertView has to be show
n in or after viewDidAppear:
is invoked on the Root View Controller. If you attempt to call show
before that, the instance may not be visible on the screen.
You can also have HumbleAlertView show only within your view of choice by calling showInView:
instead of show
.
Exposes all of the available options.
init(title: String?, message: String?, timeout: TimeInterval, dismissible: Bool)
title
The string that appears in the view's title label.
message
Descriptive text that provides more details than the title. Can be nil
.
timeout
Time interval before the alert is automatically dismissed.
dismissible
Whether the alert can be dismissed with a tap or not.
Equivalent to initWithTitle:message:timeout:dismissible:
, but assumes default values for timeout
(6
seconds) and dismissible
(true
).
init(title: String?, message: String?)
Equivalent to initWithTitle:message:timeout:dismissible:
, but assumes default values for message
(nil
) timeout
(4
seconds) and dismissible
(true
).
init(title: String?)
The vertical position of the view.
position: HumbleAlertViewPosition;
This property controls the origin of the view on the Y axis.
The default value is .bottom
.
The visual style of the view.
style: HumbleAlertViewStyle
The view can have either light text on a dark background (.dark
) or dark text over a light background (.light
).
The default value is .standart
, which maps to .light
.
A block to execute after the instance has been dismissed.
completionBlock: (() -> Void)?
The string that appears in the title of the alert.
title: String
Setting this property after initialization recalculates the view's metrics.
Descriptive text that provides more details than the title.
message: String
Setting this property after initialization recalculates the view's metrics.
The label that displays the title.
titleLabel: UILabel
The label that displays the title.
messageLabel: UILabel
A margin that prevents the alert from drawing above it.
topContentMargin: CGFloat
A margin that prevents the alert from drawing below it.
bottomContentMargin: CGFloat
Time interval before the alert is automatically dismissed.
timeout: NSTimeInterval
Whether the alert can be dismissed with a tap or not.
dismissable: Bool
A Boolean value that indicates whether the view is currently visible on the screen.
visible: Bool
Here are some current limitations in HumbleAlertView:
- Adding an HumbleAlertView while displaying a keyboard will cause it to be placed under the keyboard. This can be worked around using the
position
property.
We built HumbleAlertView because we needed it for one of our projects. If you improve it in any way, please send us a pull request. Enjoy!
Omer Karisman Lead UI/UX @ MojiLaLa |
Sahin Boydas Founder @ RemoteTeam.com |
---|
ondalabs, http://ondalabs.com