ps: oc项目可以使用DZNEmptyDataSet替代.
app 显示列表内容时, 在某一时刻可能数据为空(等待网络请求/网络请求失败)等, 添加一个空白指示页将有效缓解用户可能造成的焦虑或混乱. 并可以帮助用户处理问题.
-
支持UICollectionView & UITableView.
-
支持链式配置预置模板视图.
-
支持完全自定义视图.
-
支持更多实用与设计感的模板.
- Swift 4
- iOS 8+
- Xcode 10+
-
使用cocoapods安装
pod 'EmptyPage'
pod 'EmptyPage/Core'
-
配置空白页
let emptyView = EmptyPageView.ContentView.standard .change(hspace: .button, value: 80) .change(height: .button, value: 60) .change(hspace: .image, value: 15) .config(button: { (item) in item.backgroundColor = UIColor.blue item.contentEdgeInsets = UIEdgeInsets(top: 8, left: 20, bottom: 8, right: 20) }) .set(image: UIImage(named: "empty-1002")!) .set(title: "Connection failure", color: UIColor.black, font: UIFont.boldSystemFont(ofSize: 24)) .set(text: "Something has gone wrong with the internet connection. Let's give it another shot.", color: UIColor.black, font: UIFont.systemFont(ofSize: 15)) .set(buttonTitle: "TRY AGAIN") .set(tap: { // 点击事件 }) .mix()
-
设置空白页
tableView.setEmpty(view: emptyView) collectionView.setEmpty(view: emptyView)
-
空白页显示与切换
如果需要切换已显示的空白页可主动触发刷新.
tableView.setEmpty(view: emptyView) tableView.reloadData()
linhay: [email protected]
EmptyPage is available under the Apache License. See the LICENSE file for more info.