BubbleShowCase 1.2.0

BubbleShowCase 1.2.0

ElConfidencial Apps 维护。



BubbleShowCase

Carthage compatible Download CocoaPods platforms License: MIT

BubbleShowCase 是一个优雅且易于使用的框架,它为开发者提供了一种用户友好的气泡视图,可以显示在应用程序中以帮助用户理解功能,改进某些功能的用法或显示应用程序的入职流程。它由一个半透明的视图组成,遮挡屏幕,一个显示用户消息的气泡以及目标视图本身。

GIF

要求

  • iOS 9.0+
  • Swift 4.0+

安装

CocoaPods

pod 'BubbleShowCase'

Carthage

要使用 Carthage 将 BubbleShowCase 集成到您的 Xcode 项目中,创建一个 Cartfile 并添加

github "ECLaboratorio/BubbleShowCase-iOS"

您可以使用以下命令通过 Homebrew 安装 Carthage:

$ brew update
$ brew install carthage

如果您不知道 HomeBrew 是什么,可以查看他们的 网站 了解安装说明。

使用说明

基本使用

使用 BubbleShowCase 框架在你的应用中展示功能非常简单。您只需要使用其中一个构造函数初始化示例,按照您的需求自定义,然后调用其 show 方法

let showCase: BubbleShowCase! = BubbleShowCase(target: myBarButton)
showCase.titleText = "You know what?"
showCase.descriptionText = "You can do amazing things if you tap on this navbar button"
showCase.image = UIImage(named: "show-case-bar-button")
showCase.show()		// Simple as that

注意:您应在目标加载、设置和定位到屏幕时调用 show

支持的目标

  • UIView
  • UITableView
  • UICollectionView
  • UIBarButtonItem
  • UITabBarItem

UICollectionViewCell 和 UITableViewCell

BubbleShowCase 根据目标提供几个构造函数。在 UITableViewCell 或 UICollectionViewCell 的情况下,请使用相应的构造函数。

func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) {
	if indexPath.row == Constants.IndexPathForShowCase {
		let showCase = BubbleShowCase(cell: cell, target: nil, arrowDirection: .down)
		showCase.titleText = "Am I not in the screen?"
		showCase.descriptionText = "I'll stop the scroll and make sure the cell displays"
		showCase.shadowColor = UIColor.green
		
		showCase.show()
	}
}

UI 自定义

根据您应用的风格自定义您的示例

showCase.color = UIColor.yellow
showCase.textColor = UIColor.black
showCase.shadowColor = UIColor.black
showCase.crossColor = UIColor.red
showCase.arrowDirection = .up
showCase.titleText = "My first show case"
showCase.descriptionText = "I hope you enjoy it"
showCase.image = UIImage(named: "my-show-case-image")
showCase.delegate = self
showCase.titleFont = UIFont(name: "Roboto-Bold", size: 14)!
showCase.descriptionFont = UIFont(name: "Roboto-Regular", size: 13)!

showCase.showAnimationDuration = 0.2
showCase.dismissAnimationDuration = 0.2
showCase.flickerAnimationDuration = 0.2

// Use this to force your users to tap or perform any other gesture over the target view
showCase.isCrossDismissable = false	

连接演示案例

您需要按顺序展示多个功能吗?这很简单,您只需调用 concat(bubbleShowCase:)show(after:)。前者将参数作为下一个演示案例显示,而后者则显示参数之后的演示案例。

let firstShowCase = BubbleShowCase(...)
let secondShowCase = BubbleShowCase(...)

firstShowCase.concat(bubbleShowCase: secondShowCase)	// secondShowCase.show(after: firstShowCase)

BubbleShowCaseDelegate

遵守BubbleShowCaseDelegate以了解屏幕上的展示案例状态或接收目标上识别出的通用手势的通知。

let showCase = BubbleShowCase(...)
showCase.delegate = self

...
...

func bubbleShowCase(_ bubbleShowCase: BubbleShowCase, didTap target: UIView!, gestureRecognizer: UITapGestureRecognizer) {
	print("Target was tapped!")
}

注意:为了展示UIBarButton,必须通过自定义视图来构建它。

let myBarButton = UIBarButtonItem(customView: myCustomView)
let showCase: BubbleShowCase! = BubbleShowCase(target: myBarButton)
...
showCase.show()

有关更多信息,请查看我们的示例应用

如果您有任何问题或反馈,请访问问题部分
请随时合作,使这个框架更好。

许可

BubbleShowCase-iOS 可在MIT许可下使用。有关更多详情,请参阅LICENSE 文件。