Arale
A柄为 UITableView, UICollectionView 或任何 UIScrollView 子类提供的自定义伸展头部。
演示
ZulwiyozaPutra创建
Arale,由- 支持
UITableView
、UICollectionView
或任何UIScrollView
子类。 - 数据源和代理独立性:可以添加到现有的视图控制器中而不会干扰您的现有
delegate
或dataSource
。 - 不需要继承自定义视图控制器或使用自定义
UICollectionViewLayout
。
如果您在项目中使用这个库,我会很高兴知道的![邮件地址]
用法
要向您表格或集合视图添加伸展式头部,您只需要这样做
import Arale
var araleHeaderView: AraleHeaderView!
...
let araleHeaderView = AraleHeaderView(minHeight: 256.0, backgroundImage: myBackgroundImage)
araleHeaderView.delegate = self
self.tableView.addSubview(self.araleHeaderView)
...
// In case you want to add an UIActivityIndicatorView
// To handle action if the AraleHeaderView has resize to maxHeight you can implement a AraleHeaderViewDelegate conformed UIViewController
araleHeaderView.delegate = self
...
// And implement headerViewDidReachMaxHeight to get event when the araleHeaderView did reach the maximum height
func headerViewDidReachMaxHeight(headerView: AraleHeaderView) {
NSLog("%@", "Start Refreshing")
headerView.activityIndicatorView.stopAnimating()
}
...
// AraleHeaderViewDelegate comes with three optional delegate method
func headerViewWillResizeFrame(headerView: AraleHeaderView)
func headerViewDidResizeFrame(headerView: AraleHeaderView)
func headerViewDidReachMaxHeight(headerView: AraleHeaderView)
...
配置
您可以在拉伸式头部视图中添加可选的 UIViewActivityIndicatorView
let myActivityIndicatorview = UIActivityIndicatorView(style: .white)
self.araleHeadeView.activityIndicatorView = myActivityIndicatorView
如果您不需要活动指示器,则activityIndicatorView
将不会渲染,如果其值仍为nil
安装
Arale可以通过CocoaPods获取。要安装它,只需将以下行添加到您的Podfile中,您可以通过查看示例Podfile来了解其外观
pod "Arale"
作者
贡献
欢迎贡献!如果您找到解决方案或有改进,请不要犹豫,打开一个pull request!
许可
Arale
可在MIT许可下使用。有关更多信息,请参阅LICENSE文件。
如果您的应用程序使用Arale
,我将很高兴如果您通过Twitter或电子邮件联系我。