InStatEventlistView
InStatEventlistView 是一个 UI 组件,其中封装了与按钮交互的逻辑:播放、下载、分享、检查和选择视角
用法
代码
要在代码中使用 InStatEventlistView
,您只需创建一个新的实例
fileprivate lazy var eventlistView: InStatEventlistView = {
let eventlist = InStatEventlistView()
eventlist.dataSource = self
eventlist.delegate = self
eventlist.translatesAutoresizingMaskIntoConstraints = false
return eventlist
}()
并将其添加到您期望的视图中作为子视图
override func viewDidLoad() {
super.viewDidLoad()
view.addSubview(eventlistView)
}
代理
您可以使用 InStatEventlistViewDelegate
来处理事件
func eventlistView(_ eventlistView: InStatEventlistView, heightForHeaderInSection section: Int) -> CGFloat
func eventlistView(_ eventlistView: InStatEventlistView, didSelect item: Row, at indexPath: IndexPath)
func eventlistView(_ eventlistView: InStatEventlistView, didDeselect item: Row, at indexPath: IndexPath)
func eventlistView(_ eventlistView: InStatEventlistView, didShare item: Row, at indexPath: IndexPath)
func eventlistView(_ eventlistView: InStatEventlistView, didDownload item: Row, at indexPath: IndexPath)
func eventlistView(_ eventlistView: InStatEventlistView, didChangePlaySelectionState state: Bool, forItem item: Row, at indexPath: IndexPath)
并且使用 InStatEventlistViewDataSource
来用数据填充组件
func numberOfSections(in eventlistView: InStatEventlistView) -> Int
func eventlistView(_ eventlistView: InStatEventlistView, numberOfRowsInSection section: Int) -> Int
func setEvents(for eventlistView: InStatEventlistView) -> [Section]
示例
要运行示例项目,首先克隆仓库,然后在示例目录中执行pod install
。
安装
InStatEventlistView可通过CocoaPods获取。安装它,只需将以下行添加到您的Podfile中
pod 'InStatEventlistView'
作者
贝斯兰·图卢拉罗夫 | @JiromTomson
许可证
MIT License
Copyright (c) 2018 Beslan Tularov
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.