BSFloatListView
示例
要运行示例项目,请克隆仓库,然后首先从 Example 目录运行 pod install
。
要求
iOS 10.0+
Swift 4.2+
用法
首先,
步骤 0. 导入 BSFloatListView
步骤 1. 以实例变量的形式程序化创建实例
声明并创建实例如下所示。
BSFloatListView 只支持程序化方式。
/**
* initiating floatListView instance..
/// Used to create floatList instance from nib file to return.
///
/// - warning: Mind whether isSticky is true or false will make difference of usage. Check detail in example source.
/// - parameter observedTouchView: a targetView to react on.
/// - parameter dataList: string array to display on the list.
/// - parameter touchDetectionMode: choose recognizer type for either short tap(.short) or long press(.long)
/// - parameter isSticky: if true, rather than floating around, stick to and show floatListView on a given observedTouchView in the first parameter.
/// - returns: BSFloatListView instance
*/
private lazy var floatListView: BSFloatListView = { [unowned self] in
let floatListView = BSFloatListView.initialization(
on:
observedTouchView, // a view to stick to and to focus on.
with:
dataList, // data list to show in the BSFloatListView ["Java", "Swift", "Scala", "Kotlin", "C++", "Clojure"]
touchDetectionMode:
touchDetectionMode, // either .short or .long. if you want long press to invoke BSFloatListView, go for .long.
isSticky:
isSticky // true
)
/// a closure for which list to choose.
floatListView.didSelectRowAtClosure = { [unowned self] indexPath in
print("clicked at : ", indexPath.row)
}
return floatListView
}()
isSticky 是重要的。
如果 isSticky 为 true,BSFloatListView 会一直停留在你指定的 observedTouchView 的 CGPoint(x:0, y:0) 位置,无论用户在哪个位置点击,只要在 observedTouchView 的帧内使用 BSFloatListView。
否则,BSFloatListView 只会跟随用户在 observedTouchView 帧内点击的位置。
步骤 1. 在 viewDidLoad 中,应用 readyToUse() 方法来准备显示 BSFloatListView.
就像以下这样。
override func viewDidLoad() {
super.viewDidLoad()
/**
* Ready to use BSFloatListView
*/
floatListView.readyToUse()
}
就是这样!尽情享受 BSFloatListView 吧! :)
安装
BSFloatListView可以通过CocoaPods获取。要安装它,只需将以下行添加到您的Podfile中。
pod 'BSFloatListView'
作者
许可证
BSFloatListView受MIT许可证的许可。有关更多信息,请参阅LICENSE文件。