mirror of
https://github.com/HackPlan/TTGSnackbar.git
synced 2026-04-24 03:55:02 +08:00
Update README
This commit is contained in:
38
README.md
38
README.md
@@ -5,7 +5,7 @@ A Swift based implementation of the Android Snackbar for iOS
|
||||
[](https://github.com/zekunyan/TTGSnackbar)
|
||||
[](https://github.com/zekunyan/TTGSnackbar)
|
||||
|
||||

|
||||

|
||||
|
||||
# About
|
||||
TTGSnackbar is useful for showing a brief message at the bottom of the screen with an action button.
|
||||
@@ -13,6 +13,10 @@ It appears above all other elements on screen and only one can be displayed at a
|
||||
It disappears after a timeout or after user click the action button.
|
||||
|
||||
# Installation
|
||||
### Requirement
|
||||
Swift 2.2
|
||||
iOS 8+
|
||||
|
||||
### CocoaPods
|
||||
You can use [CocoaPods](http://cocoapods.org) to install `TTGSnackbar` by adding it to your `Podfile`:
|
||||
|
||||
@@ -40,13 +44,13 @@ import TTGSnackbar
|
||||
## Show a simple message
|
||||

|
||||
```
|
||||
let snackbar = TTGSnackbar.init(message: "Message", duration: TTGSnackbarDuration.Short)
|
||||
let snackbar = TTGSnackbar.init(message: "Message", duration: .Short)
|
||||
snackbar.show()
|
||||
```
|
||||
## Show a simple message with an action button
|
||||

|
||||
```
|
||||
let snackbar = TTGSnackbar.init(message: "Message", duration: TTGSnackbarDuration.Middle, actionText: "Action")
|
||||
let snackbar = TTGSnackbar.init(message: "Message", duration: .Middle, actionText: "Action")
|
||||
{ (snackbar) -> Void in
|
||||
NSLog("Click action!")
|
||||
}
|
||||
@@ -56,7 +60,7 @@ snackbar.show()
|
||||
## Show a simple message with a long running action
|
||||

|
||||
```
|
||||
let snackbar = TTGSnackbar.init(message: "Message", duration: TTGSnackbarDuration.Forever, actionText: "Action")
|
||||
let snackbar = TTGSnackbar.init(message: "Message", duration: .Forever, actionText: "Action")
|
||||
{ (snackbar) -> Void in
|
||||
NSLog("Click action!")
|
||||
// Dismiss manually after 3 seconds
|
||||
@@ -67,6 +71,24 @@ let snackbar = TTGSnackbar.init(message: "Message", duration: TTGSnackbarDuratio
|
||||
snackbar.show()
|
||||
```
|
||||
|
||||
## Show a simple message with two action buttons
|
||||

|
||||
```
|
||||
let snackbar: TTGSnackbar = TTGSnackbar.init(message: "Two actions !", duration: .Long)
|
||||
|
||||
// Action 1
|
||||
snackbar.actionText = "Yes"
|
||||
snackbar.actionTextColor = UIColor.greenColor()
|
||||
snackbar.actionBlock = { (snackbar) in NSLog("Click Yes !") }
|
||||
|
||||
// Action 2
|
||||
snackbar.secondActionText = "No"
|
||||
snackbar.secondActionTextColor = UIColor.yellowColor()
|
||||
snackbar.secondActionBlock = { (snackbar) in NSLog("Click No !") }
|
||||
|
||||
snackbar.show()
|
||||
```
|
||||
|
||||
# Customization
|
||||
### Message
|
||||
`message: String` defines the message to diaplay.
|
||||
@@ -98,6 +120,14 @@ When you set `Forever`, the snackbar will show an activity indicator after user
|
||||
public typealias TTGActionBlock = (snackbar: TTGSnackbar) -> Void
|
||||
```
|
||||
|
||||
### Second action title, color, font and callback
|
||||
```
|
||||
secondActionText: String
|
||||
secondActionTextColor: UIColor
|
||||
secondActionTextFont: UIFont
|
||||
secondActionBlock: TTGActionBlock?
|
||||
```
|
||||
|
||||
### Dismiss callback
|
||||
`dismissBlock: TTGDismissBlock?` will be called when snackbar dismiss automatically or when user click action button to dismiss the snackbar.
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user