FlexibleTooltips 0.3.0

FlexibleTooltips 0.3.0

Chen-Hao Chiang 维护。



FlexibleTooltips

CI Status Version License Platform

示例

要运行示例项目,请克隆仓库,并首先从 Example 目录中运行 pod install

使用 CocoaPods 设置

  • pod 'FlexibleTooltips' 添加到您的 Podfile
  • 运行 pod install
  • 运行 open App.xcworkspace

使用方法

创建工具提示

要创建工具提示,您需要指定箭头尖端的坐标、箭头位置(在工具提示矩形顶部或底部)以及工具提示矩形最大宽度和文本。

let tooltip = FlexibleTooltip(arrowTip: CGPoint(x: 50, y: 150), arrow: .bottom, maxWidth: CGFloat(200), text: "Hello world. This is the first tooltip.")

自定义 tooltip

要自定义 tooltip,请更改 tooltip.configuration 中的值。

tooltip.configuration.drawing.foregroundColor = UIColor.black
tooltip.configuration.drawing.backgroundColor = UIColor.lightGray
tooltip.configuration.drawing.borderColor = UIColor.gray
tooltip.configuration.drawing.borderWidth = 2

FlexibleTooltipManager

创建一个 FlexibleTooltipManager 用于管理 tooltip。

let tooltip1 = FlexibleTooltip(arrowTip: CGPoint(x: 50, y: 150), arrow: .bottom, maxWidth: CGFloat(200), text: "Hello world. This is the first tooltip.")

let tooltip2 = FlexibleTooltip(arrowTip: CGPoint(x: 150, y: 250), arrow: .bottom, maxWidth: CGFloat(200), text: "How about this? This is the second tooltip.")

let tooltip3 = FlexibleTooltip(arrowTip: CGPoint(x: 200, y: 200), arrow: .top, maxWidth: CGFloat(200), text: "This is the final tooltip. You're almost finished!")

let tooltipManager = FlexibleTooltipManager(view: self.view)

tooltipManager.addTooltip(tooltip1)
tooltipManager.addTooltip(tooltip2)
tooltipManager.addTooltip(tooltip3)
tooltipManager.startDisplayTips()

委托方法

如果您正在使用 FlexibleTooltipManager 来管理 tooltip,请将 ViewController 设置为 FlexibleTooltipManagerDelegate 并遵循该协议。

extension ViewController: FlexibleTooltipManagerDelegate {
  func userDidFinishTips() {
    print("User saw all tips.")
  }

  func tooltipTapped() {
    tooltipManager.displayNextTip()
  }
}

安装

FlexibleTooltips 通过 CocoaPods 提供。要安装,只需将以下行添加到您的 Podfile 中

pod 'FlexibleTooltips'

作者

[email protected]

许可

FlexibleTooltips 在 MIT 许可下可用。有关更多信息,请参阅 LICENSE 文件。