TAlertView
is a flat customizable alertView, written in Swift
- iOS 12.0+
- Swift 5
TAlertView
is available through CocoaPods. To install
it, simply add the following line to your Podfile:
pod 'TAlertViews'
Second, install TAlertView
into your project:
pod install
TAlertView
is designed for Swift 5. To depend on the logging API package, you need to declare your dependency in your Package.swift
.package(url: "https://github.com/fanta1ty/TAlertView.git", brand: "master"),
let alert = TAlertView()
alert.showAlertInView(
view: self,
withTitle: "Alert Title",
withSubtitle: "This is your alert's subtitle",
withCustomImage: nil,
withDoneButtonTitle: "",
andButtons: []
)
-
withTitle (String): You can leave the title as
""
or give it aString
. -
withSubtitle (String):
TAlertView
always requires a subtitle, even if you want just a few words, add it here instead of the title (then leave the title as ""). -
withCustomImage (UIImage?): You can leave this image as
nil
or give it aUIImage
which will show at the top of the alert. -
withDoneButtonTitle (String): You can leave this as
""
to show "Ok" as the dismiss button for the alert view, or give it anString
. -
andButtons ([String]): If you want to add buttons to your alert, simply add an array of 1 or 2 button titles as
String
here, anything more will be ignored as 2 is the max custom buttons you can add
TAlertView
comes with 3 pre-designed custom alert types. Success, Caution, or Warning, simply add the type while initializing the TAlertView
.
let alert = TAlertView()
alert.makeAlertTypeSuccess()
alert.showAlertInView(
view: self,
withTitle: "Alert Title",
withSubtitle: "This is your alert's subtitle",
withCustomImage: nil,
withDoneButtonTitle: "",
andButtons: []
)
let alert = TAlertView()
alert.makeAlertTypeCaution()
alert.showAlertInView(
view: self,
withTitle: "Alert Title",
withSubtitle: "This is your alert's subtitle",
withCustomImage: nil,
withDoneButtonTitle: "",
andButtons: []
)
let alert = TAlertView()
alert.makeAlertTypeWarning()
alert.showAlertInView(
view: self,
withTitle: "Alert Title",
withSubtitle: "This is your alert's subtitle",
withCustomImage: nil,
withDoneButtonTitle: "",
andButtons: []
)
There are multiple ways you can dismiss an TAlertView
When the user taps anywhere outside the alert, you can dismiss it by adding this line:
alert.dismissOnOutsideTouch = true
Dismiss the AlertView when a certain time has elapsed after the AlertView is presented, by adding this line:
alert.autoHideSeconds = 5
thinhnguyen12389, thinhnguyen12389@gmail.com
TAlertView is available under the MIT license. See the LICENSE file for more info.