YHHeadScrollView 1.1.0

YHHeadScrollView 1.1.0

测试已测试
语言语言 SwiftSwift
许可证 MIT
发布上次发布2017年6月
SwiftSwift 版本3.0
SPM支持 SPM

‘developeryh‘ 维护。



  • 作者:
  • developeryh

YHHeadScrollView

仿mac网页云音乐的头部滚动视图

示例

生成此jpg的代码位于ExampleProject/目录中

安装

在应用中使用YHHeadScrollView的最简单方式是通过CocoaPods。更多信息请参阅“入门”指南

Podfile

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需要注意的提示

  • 如果您的项目是使用objective-c构建的,您必须创建一个名为“yourobjectName-Bridging-Header.h”的文件。
  • 然后将“yourobjectName-Bridging-Header.h”的文件路径复制到您的target的Build Settings -> Objective-C Bridging Header中
  • 最后在您使用的文件中添加“#import "yourobjectName-Swift.h",然后您可以像以下代码那样初始化:
- (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数组。

  • 如果imageUrlStrArr.count = 0,将有一个不能触摸填充整个视图的默认imageView。
  • 如果imageUrlStrArr.count = 1,将有一个可以触摸填充整个视图的imageView。
  • 如果imageUrlStrArr.count = 2,它将像示例gif一样滚动,但是相同的imageView会自动复制到imageUrlStrArr以达到3个数量。
  • 如果imageUrlStrArr.count >=3,它将像示例gif一样滚动

####placeImageStr

您必须提供您bundle中的imageName,当imageUrl无效时将使用它。

###Optonal ####timeScrollInterval: –defalut:2

imageView滚动的时间间隔,默认时间是2秒钟

####yHHeadScrollViewClosure(Nsinteger dataTag)

imageView触摸事件的闭包,返回dataTag,因此您知道哪个imageView被触摸。

开发者

作者:developeryh

邮箱:[email protected]

如此友好,对吧?所以如果你有任何疑虑,请联系我,如果喜欢,别忘了点赞。