FastMessage
安装
CocoaPods
将以下代码插入您的 Podfile 中:
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '10.0'
use_frameworks!
target '<Your Target Name>' do
pod 'FastMessage'
end
用途
默认显示
- 将FastMessage项目导入进来
import FastMessage
- 显示屏幕上的消息只使用一个函数。
override func viewDidLoad() {
super.viewDidLoad()
view.showToast(title: String?, message: String)
}
这个函数有一个扩展版本(只有前两个参数是必需的,其余参数都有默认值)。
override func viewDidLoad() {
super.viewDidLoad()
view.showToast(title: String?,
message: String,
durationShow: Double,
duration: Double,
durationHidden: Double,
typeView: TypeView,
typeInstallation: TypeInstallation)
}
其中durationShow, duration, durationHidden之和是消息在屏幕上存在的时间。
typeView - 你想显示的UIView类型。有两种类型,.Default(styleToast: StyleToast)可以选择两种颜色(.black和.white),还有.custom(view: UIView),其中的view是你的自定义UIView。
填写typeInstalation - 这是选择你如何在屏幕上安装UIView的方式。有两种模式,.Default(positionToast: PositionToast, minHeightView: CGFloat, minWidthView: CGFloat),其中positionToast是选择屏幕上的位置,minHeightView和minWidthView是UIView的最小尺寸;第二种模式是.myConstraints(completion: (UIView) -> Void),你可以有机会自主设置UIView。
使用《.myConstraints`完成`的示例:
override func viewDidLoad() {
super.viewDidLoad()
view.showToast(title: "Заголовок",message: "Сообщение", typeInstallation: .myConstraints(completion: { myView in
myView.translatesAutoresizingMaskIntoConstraints = false
self.view.addSubview(myView)
self.view.addConstraints([
myView.heightAnchor.constraint(greaterThanOrEqualToConstant: 44),
myView.widthAnchor.constraint(equalToConstant: 270),
myView.centerXAnchor.constraint(equalTo: self.view.centerXAnchor),
myView.centerYAnchor.constraint(equalTo: self.view.centerYAnchor)
])
}))
}
通讯
请写明要添加或删除的内容
telegram: @IvanBogdaanov
许可证
FastMessage遵从MIT许可证发布。详细信息见LICENSE。