测试已测试 | ✗ |
语言语言 | SwiftSwift |
许可证 | MIT |
发布上次发布 | 2017年6月 |
SwiftSwift 版本 | 3.0 |
SPM支持 SPM | ✗ |
由 ‘developeryh‘ 维护。
仿mac网页云音乐的头部滚动视图
生成此jpg的代码位于ExampleProject/
目录中
在应用中使用YHHeadScrollView的最简单方式是通过CocoaPods。更多信息请参阅“入门”指南。
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
use_frameworks!
pod "YHHeadScrollView", "~> 1.0.2"
您也可以克隆项目并将YHHeadScrollView/YHHeadScrollView.{h,swift}文件复制到您的项目中。
OC和Swift的提示
如果YHHeadScrollView的superView是scrollView/tableView/collectionView,则必须让YHHeadScrollView的superView.delaysContentTouches = false/NO。
####Objective-C需要注意的提示
- (void)viewDidLoad{
[super viewDidLoad];
...
YHHeadScrollView *topImgView = [[YHHeadScrollView alloc]init];
topImgView.imageUrlStrArr = @[@"http://pic33.nipic.com/20130928/4420504_005335593000_2.jpg",@"http://pic.58pic.com/58pic/13/43/94/88258PICeV4_1024.jpg",@"http://pic26.nipic.com/20130127/9391931_094607395166_2.jpg"];
topImgView.placeImageStr = @"placeImageStr"
topImgView.timeScrollInterval = 3
topImgView.yHHeadScrollViewClosure = ^(NSInteger dataTag){
//call on the Correspondence's View be touch
};
[self.view addSubview:topImgView];
...
}
####Swift在Swift上,如果您有一个tableView,您可以这样做:
func loadSubViews(){
...
self.view.addSubview(tableView!)
self.tableView?.tableHeaderView = self.tableViewHeadView
...
}
lazy var tableViewHeadView:YHHeadScrollView? = {
let tableViewHeadView = YHHeadScrollView.init(frame: CGRectMake(0, 0, UIScreen.mainScreen().bounds.width, 150))
tableViewHeadView.imageUrlStrArr = ["http://pic33.nipic.com/20130928/4420504_005335593000_2.jpg","http://pic.58pic.com/58pic/13/43/94/88258PICeV4_1024.jpg","http://pic26.nipic.com/20130127/9391931_094607395166_2.jpg","http://pic61.nipic.com/file/20150311/20613793_172336144198_2.png","http://pic.58pic.com/10/20/29/99bOOOPIC77.jpg","http://pic15.nipic.com/20110630/6322714_105943746342_2.jpg","http://pic26.nipic.com/20130127/9391931_094607395166_2.jpg"]
tableViewHeadView.placeImageStr = "placeImageStr"
tableViewHeadView.timeScrollInterval = 3
tableViewHeadView.yHHeadScrollViewClosure = {(dataTag) in
//call on the Correspondence's View be touch
...
print(dataTag)
...
}
return tableViewHeadView
}()
###Requrid ####imageUrlStrArr
图片urlStrs数组。
####placeImageStr
您必须提供您bundle中的imageName,当imageUrl无效时将使用它。
###Optonal ####timeScrollInterval: –defalut:2
imageView滚动的时间间隔,默认时间是2秒钟
####yHHeadScrollViewClosure(Nsinteger dataTag)
imageView触摸事件的闭包,返回dataTag,因此您知道哪个imageView被触摸。
作者:developeryh
如此友好,对吧?所以如果你有任何疑虑,请联系我,如果喜欢,别忘了点赞。