william-weng/wwtoast
- A small tool imitating Android's [Toast](https://developer.android.com/guide/topics/ui/notifiers/toasts) function...
[Introduction - 簡介](https://swiftpackageindex.com/William-Weng)
[Installation with Swift Package Manager](https://medium.com/彼得潘的-swift-ios-app-開發問題解答集/使用-spm-安裝第三方套件-xcode-11-新功能-2c4ffcf85b4b)
dependencies: [
.package(url: "https://github.com/William-Weng/WWToast.git", .upToNextMajor(from: "1.3.0"))
]Function - 可用函式
|函式|功能| |-|-| |makeText(target:text:)|顯示文字| |makeText(_:targetFrame:)|顯示文字| |setting(backgroundViewColor:textColor:toastLength:bottomHeight:animationOptions:)|相關設定|
WWToastDelegate
|函式|功能| |-|-| |toastDisplay(_:textQueue:text:status:)|文字框顯示的狀態|
Example
import UIKit
import WWToast
final class ViewController: UIViewController {
@IBOutlet var showToastLabels: [UILabel]!
override func viewDidLoad() {
super.viewDidLoad()
initSetting()
}
@objc func showToast(_ recognizer: UITapGestureRecognizer) {
guard let label = recognizer.view as? UILabel,
let text = label.text
else {
return
}
WWToast.shared.makeText(text)
}
}
private extension ViewController {
func initSetting() {
WWToast.shared.setting(backgroundViewColor: .systemPink)
showToastLabels.forEach { label in
let tapGesture = UITapGestureRecognizer(target: self, action: #selector(Self.showToast(_:)))
label.addGestureRecognizer(tapGesture)
}
}
}Package Metadata
Repository: william-weng/wwtoast
Default branch: main
README: README.md