//懒加载    
  //顶部需要拉伸自定义视图
lazy var headView:MyHeaderView = {
//let hframe = CGRect(x: 0, y: 0, width: swidth, height: swidth/self.imgRation)
// let hview = Bundle.main.loadNibNamed("MyInfoHeaderView", owner: nil, options: nil)?.first as! MyInfoHeaderView
//return hview;
}() //MARK:1)集合视图
self.collectionView?.addSubview(self.headView)
override func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
if indexPath.section == 0 { //顶部返回一个空的cell
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: reuseIdentifier, for: indexPath)
return cell
}
.... func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
if indexPath.section == 0 {//顶部
return CGSize(width: swidth, height:200.0 )
}
.... //MARK:2)列表视图
self.tableView?.addSubview(self.headView)
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
if indexPath.section == 0 { //顶部返回一个空的cell
var cell = tableView.dequeueReusableCell(withIdentifier: reuseIdentifier)
return cell!
}
.... override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
if indexPath.section == 0{
return 200.0;
}
.... //MARK:拉伸效果实现位置
override func scrollViewDidScroll(_ scrollView: UIScrollView) {
let point = scrollView.contentOffset;
if point.y <= 0 {//下拉
//self.headView.frame.size.height = swidth/imgRation - point.y
//self.headView.frame.size.width = self.headView.frame.size.height*imgRation
//self.headView.frame.origin.x = (swidth - self.headView.frame.size.width)/2
//self.headView.frame.origin.y = point.y
//self.headView.titleImgLeft.constant = 18 - self.headView.frame.origin.x
//self.mainNavView.backgroundColor = UIColor.clear
//self.mainNavView.searImg.image = UIImage(named: "搜索框r")
}else{//上推
//if point.y >= (self.headView.frame.height - 64){
//self.mainNavView.searImg.image = UIImage(named: "搜索框w")
//self.mainNavView.searchText.backgroundColor = UIColor.white
//}
//self.headView.titleImgLeft.constant = 18
// self.mainNavView.backgroundColor = UIColor(red:245/255.0, green:74/255.0, blue:48/255.0, alpha: point.y/(self.headView.frame.height - 64))
}
} 

最新文章

  1. 1Z0-053 争议题目解析607
  2. jprofiler_监控远程linux服务器的JVM进程(实践)
  3. android NDK 生成so 文件流程-ecplice
  4. Bootstrap 更改Navbar默认样式
  5. JBoss 系列四十八:JBoss 7/WildFly 使用TCP构建集群
  6. ***mysql中经度纬度字段用什么存储(关于mysql的float和decimal区别)
  7. Inno Setup 系统托盘图标插件 TrayIconCtrl V1.5
  8. 配置Log4J(转载)
  9. pyqt样式表语法笔记(下)--原创
  10. 【ASP.NET MVC 学习笔记】- 09 Area的使用
  11. 【原创】python实现视频内的face swap(换脸)
  12. 【BZOJ4028】[HEOI2015]公约数数列(分块)
  13. .net core 连接mysql
  14. 一个会学习(观察-&gt;活学-&gt;求变)的人,在任何领域都能变得强大无比
  15. 减小ipa包大小
  16. ADB文件及文件夹操作
  17. dedecms后台左侧菜单500错误怎么处理
  18. MySQL中如何实现 select top n
  19. IN_ITEMBOMROUTING中的数据被过滤 到IN_ITEMBOMROUTING_TEMP
  20. 在有 UI 线程参与的同步锁(如 AutoResetEvent)内部使用 await 可能导致死锁

热门文章

  1. iOS.Crash.Case-[__NSArrayM objectForKeyedSubscript:]
  2. JQuery Deferred 对象
  3. js 闭包 弊端
  4. linux系统中的进程状态分析
  5. RunAsPolicy Exit Code 1替代
  6. pc-H5 适配方案
  7. IOS初级:导航控制器
  8. Twitter 相关APP开发
  9. KiB和KB的区别
  10. 斐波那契数列(NOIP1997)