SnackBar.swift 0.1.0

SnackBar.swift 0.1.0

a.masri 维护。



  • Ahmad Almasri

SnackBar.swift

CI Status Version License Platform

SnackBar 通过屏幕底部的一条消息提供对操作的简短反馈。 SnackBar 包含最多两行与所执行操作直接相关的文本。它们可以包含文本操作。

截图

使用

无操作

SnackBar.make(in: self.view, message: "The Internet connection appears to be offline.", duration: .lengthLong).show()

带操作

 SnackBar.make(in: self.view, message: "The Internet connection appears to be offline.", duration: .lengthLong).setAction(with: "Retry", action: {

   print("retry Tapped")

  }).show()

改变样式

class AppSnackBar: SnackBar {
	
	override var style: SnackBarStyle {
		var style = SnackBarStyle()
		style.background = .red
		style.textColor = .green
		return style
	}
}

 AppSnackBar.make(in: self.view, message: "The Internet connection appears to be offline.", duration: .lengthLong).show()

持续时间

持续时间
longLength 3.5
shortLength 2
无限期 手动消失或滑动 SnackBar(左侧、右侧、上侧、下侧)
自定义(CGFloat) 根据您的输入

|

样式

属性 类型 默认值
style.background UIColor UIColor.systemGray6
style.textColor UIColor UIColor.label
style.font UIFont UIFont.systemFont(ofSize: 14)
style.actionTextColorAlpha CGFloat 0.5
style.actionFont UIFont UIFont.systemFont(ofSize: 17)
style.actionTextColor UIColor UIColor.red

|

需求

  • iOS 12.0+
  • Swift 5.0+
  • Xcode 10.0+

安装

SnackBar.swift可通过CocoaPods获得。要安装它,只需将以下行添加到您的Podfile中

pod 'SnackBar.swift'

作者

Ahmad Almasri,[email protected]

许可

SnackBar.swift遵循MIT许可。有关更多信息,请参阅LICENSE文件。