Commit e542b593d21e1d88b837a41ac41a8eaf1a10dd63
1 parent
e53aaad6
认证-下滑慢拖动时 没有翻页的问题
Showing
5 changed files
with
57 additions
and
37 deletions
metaCode/Classes/Main/HomePage/Controller/AuthMainController/CNMetaCodeHomePageController.swift
| @@ -500,9 +500,27 @@ class CNMetaCodeHomePageController:CNLiveBaseViewController, NewPagedFlowViewDel | @@ -500,9 +500,27 @@ class CNMetaCodeHomePageController:CNLiveBaseViewController, NewPagedFlowViewDel | ||
| 500 | //让背景view也跟随scrollView平移量的3倍速进行移动 | 500 | //让背景view也跟随scrollView平移量的3倍速进行移动 |
| 501 | self.backgroupView.top = -fabsOffset*3 | 501 | self.backgroupView.top = -fabsOffset*3 |
| 502 | } | 502 | } |
| 503 | - | ||
| 504 | - | 503 | + func customIndexViewDidEndDragging(scrollView: UIScrollView, decelerate: Bool) { |
| 504 | + print("EndDragging\(scrollView.contentOffset.y)") | ||
| 505 | + if decelerate == false{ | ||
| 506 | + //慢拖动时处理 | ||
| 507 | + if scrollView.contentOffset.y > 0 && scrollView.contentOffset.y < KSreenHeight/2{ | ||
| 508 | + scrollView.setContentOffset(CGPoint(x: scrollView.contentOffset.x, y: 0), animated: true) | ||
| 509 | + }else if scrollView.contentOffset.y >= KSreenHeight/2 && scrollView.contentOffset.y < KSreenHeight+KSreenHeight/2{ | ||
| 510 | + scrollView.setContentOffset(CGPoint(x: scrollView.contentOffset.x, y: KSreenHeight), animated: true) | ||
| 511 | + }else if scrollView.contentOffset.y >= KSreenHeight+KSreenHeight/2 && scrollView.contentOffset.y < KSreenHeight*2+KSreenHeight/2{ | ||
| 512 | + scrollView.setContentOffset(CGPoint(x: scrollView.contentOffset.x, y: KSreenHeight*2), animated: true) | ||
| 513 | + }else{ | ||
| 514 | + | ||
| 515 | + } | ||
| 516 | + | ||
| 517 | + }else{ | ||
| 518 | + | ||
| 519 | + } | ||
| 520 | + } | ||
| 505 | func customIndexViewDidEndScroll(scrollView: UIScrollView) { | 521 | func customIndexViewDidEndScroll(scrollView: UIScrollView) { |
| 522 | + print("EndScroll\(scrollView.contentOffset.y)") | ||
| 523 | + | ||
| 506 | if scrollView.contentOffset.y == 0{//下滑页 | 524 | if scrollView.contentOffset.y == 0{//下滑页 |
| 507 | self.tabBarController?.tabBar.isHidden = true | 525 | self.tabBarController?.tabBar.isHidden = true |
| 508 | vNumPage = .VNumPageDown | 526 | vNumPage = .VNumPageDown |
metaCode/Classes/Main/HomePage/Controller/DownSlideController/CNUpSlideViewController.swift
| @@ -74,6 +74,7 @@ class CNUpSlideViewController: CNLiveBaseViewController,UITableViewDelegate,UITa | @@ -74,6 +74,7 @@ class CNUpSlideViewController: CNLiveBaseViewController,UITableViewDelegate,UITa | ||
| 74 | tableView.dataSource = self | 74 | tableView.dataSource = self |
| 75 | tableView.delegate = self | 75 | tableView.delegate = self |
| 76 | tableView.separatorStyle = .none | 76 | tableView.separatorStyle = .none |
| 77 | + tableView.bounces = false | ||
| 77 | // tableView.register(CNDownSlideSingleCourseCell.self, forCellReuseIdentifier: kCNLiveDownSlideCellIdentifier) | 78 | // tableView.register(CNDownSlideSingleCourseCell.self, forCellReuseIdentifier: kCNLiveDownSlideCellIdentifier) |
| 78 | tableView.register(CNLiveDownSlideRecommendCell.self, forCellReuseIdentifier: kCNLiveDownSlideRecommendCellIdentifier) | 79 | tableView.register(CNLiveDownSlideRecommendCell.self, forCellReuseIdentifier: kCNLiveDownSlideRecommendCellIdentifier) |
| 79 | tableView.register(CNLiveDownSlideTodayRecommendCell.self, forCellReuseIdentifier: kCNLiveDownSlideTodayRecommendCellIdentifier) | 80 | tableView.register(CNLiveDownSlideTodayRecommendCell.self, forCellReuseIdentifier: kCNLiveDownSlideTodayRecommendCellIdentifier) |
metaCode/Classes/Main/HomePage/View/VerticalViews/CNCustomIndexView.swift
| @@ -72,12 +72,13 @@ class CNCustomIndexTopView : UIView{ | @@ -72,12 +72,13 @@ class CNCustomIndexTopView : UIView{ | ||
| 72 | 72 | ||
| 73 | protocol CNCustomIndexViewDelegate:NSObjectProtocol{ | 73 | protocol CNCustomIndexViewDelegate:NSObjectProtocol{ |
| 74 | /// 当前scrollView 将要开始滚动 | 74 | /// 当前scrollView 将要开始滚动 |
| 75 | - func customIndexViewWillBeiginScroll(scrollView :UIScrollView); | 75 | + func customIndexViewWillBeiginScroll(scrollView :UIScrollView) |
| 76 | ///当前scrollView 滚动中 | 76 | ///当前scrollView 滚动中 |
| 77 | - func customIndexViewDidScroll(scrollView :UIScrollView); | ||
| 78 | - ///当前scrollView 已经结束滚动 | ||
| 79 | - func customIndexViewDidEndScroll(scrollView :UIScrollView); | ||
| 80 | - | 77 | + func customIndexViewDidScroll(scrollView :UIScrollView) |
| 78 | + ///当前scrollView 已经结束滚动(清扫 减速的结束) | ||
| 79 | + func customIndexViewDidEndScroll(scrollView :UIScrollView) | ||
| 80 | + ///当前scrollView 已经结束拖拽滚动(慢拖动结束) | ||
| 81 | + func customIndexViewDidEndDragging(scrollView :UIScrollView,decelerate:Bool) | ||
| 81 | } | 82 | } |
| 82 | 83 | ||
| 83 | class CNCustomIndexView:PGIndexBannerSubiew, UIScrollViewDelegate, WJColorChangeDelegate{ | 84 | class CNCustomIndexView:PGIndexBannerSubiew, UIScrollViewDelegate, WJColorChangeDelegate{ |
| @@ -302,8 +303,7 @@ class CNCustomIndexView:PGIndexBannerSubiew, UIScrollViewDelegate, WJColorChange | @@ -302,8 +303,7 @@ class CNCustomIndexView:PGIndexBannerSubiew, UIScrollViewDelegate, WJColorChange | ||
| 302 | 303 | ||
| 303 | ///WJColorChange 代理方法 滚动时候回调 传出当前的滚动视图 | 304 | ///WJColorChange 代理方法 滚动时候回调 传出当前的滚动视图 |
| 304 | func wjColorScrollViewScroll(_ scrollView: UIScrollView!) { | 305 | func wjColorScrollViewScroll(_ scrollView: UIScrollView!) { |
| 305 | - | ||
| 306 | - let tag: NSInteger = self.tag | 306 | + let tag: NSInteger = self.tag |
| 307 | let defaultOffset: CGFloat = self.frame.size.height | 307 | let defaultOffset: CGFloat = self.frame.size.height |
| 308 | 308 | ||
| 309 | let currentOffset: CGFloat = scrollView.contentOffset.y | 309 | let currentOffset: CGFloat = scrollView.contentOffset.y |
| @@ -323,7 +323,7 @@ class CNCustomIndexView:PGIndexBannerSubiew, UIScrollViewDelegate, WJColorChange | @@ -323,7 +323,7 @@ class CNCustomIndexView:PGIndexBannerSubiew, UIScrollViewDelegate, WJColorChange | ||
| 323 | } | 323 | } |
| 324 | 324 | ||
| 325 | //当self.baseScrollView的偏移量大于 self.baseScrollView.height时,显示上滑提醒view | 325 | //当self.baseScrollView的偏移量大于 self.baseScrollView.height时,显示上滑提醒view |
| 326 | - if(currentOffset > self.baseScrollView.height){ | 326 | + if(currentOffset >= self.baseScrollView.height){ |
| 327 | self.upSlideViewRemindView.top = self.height - (currentOffset - self.baseScrollView.height)*1.5 | 327 | self.upSlideViewRemindView.top = self.height - (currentOffset - self.baseScrollView.height)*1.5 |
| 328 | } | 328 | } |
| 329 | //上滑滑动到临近值,让upSlideViewRemindView位置一直停留在底部,并慢慢消失 | 329 | //上滑滑动到临近值,让upSlideViewRemindView位置一直停留在底部,并慢慢消失 |
| @@ -351,29 +351,8 @@ class CNCustomIndexView:PGIndexBannerSubiew, UIScrollViewDelegate, WJColorChange | @@ -351,29 +351,8 @@ class CNCustomIndexView:PGIndexBannerSubiew, UIScrollViewDelegate, WJColorChange | ||
| 351 | let downSlideViewRemindViewMinOffset: CGFloat = self.baseScrollView.height-self.downSlideViewRemindView.height | 351 | let downSlideViewRemindViewMinOffset: CGFloat = self.baseScrollView.height-self.downSlideViewRemindView.height |
| 352 | self.downSlideViewRemindView.alpha = (20-(downSlideViewRemindViewMinOffset - currentOffset))/20.00 | 352 | self.downSlideViewRemindView.alpha = (20-(downSlideViewRemindViewMinOffset - currentOffset))/20.00 |
| 353 | 353 | ||
| 354 | - //让系统及时更新downSlideViewRemindView | ||
| 355 | -// self.downSlideViewRemindView.setNeedsLayout() | ||
| 356 | -// self.downSlideViewRemindView.layoutIfNeeded() | ||
| 357 | } | 354 | } |
| 358 | - | ||
| 359 | - | ||
| 360 | - /**控制缩放范围在一定范围*/ | ||
| 361 | -// let mainViewOffset:CGFloat = abs(currentOffset - self.baseScrollView.height) | ||
| 362 | -// if (mainViewOffset < 100) { | ||
| 363 | -// var scale: CGFloat = 1.0 | ||
| 364 | -// | ||
| 365 | -// if (currentOffset < self.baseScrollView.height) { | ||
| 366 | -// //下滑时,计算scale方法 | ||
| 367 | -// scale = currentOffset/self.baseScrollView.height | ||
| 368 | -// } | ||
| 369 | -// else { | ||
| 370 | -// //上滑时,计算scale方法 | ||
| 371 | -// scale = self.baseScrollView.height/currentOffset | ||
| 372 | -// } | ||
| 373 | -// | ||
| 374 | -// self.mainView.scaledView(scale: scale) | ||
| 375 | -// } | ||
| 376 | - | 355 | + |
| 377 | /**隐藏顶部导航**/ | 356 | /**隐藏顶部导航**/ |
| 378 | let topNavViewAlpha: CGFloat = 1.0 - (self.baseScrollView.height * 2 - currentOffset)/(self.baseScrollView.height*0.5) | 357 | let topNavViewAlpha: CGFloat = 1.0 - (self.baseScrollView.height * 2 - currentOffset)/(self.baseScrollView.height*0.5) |
| 379 | if(topNavViewAlpha > 0){ | 358 | if(topNavViewAlpha > 0){ |
| @@ -397,10 +376,23 @@ class CNCustomIndexView:PGIndexBannerSubiew, UIScrollViewDelegate, WJColorChange | @@ -397,10 +376,23 @@ class CNCustomIndexView:PGIndexBannerSubiew, UIScrollViewDelegate, WJColorChange | ||
| 397 | 376 | ||
| 398 | } | 377 | } |
| 399 | 378 | ||
| 379 | + //结束拖拽时 , 慢拖动时不走wjColorEndScroll 走本方法 | ||
| 380 | + func wjColorScrollViewDidEndDragging(_ scrollView: UIScrollView!, decelerate: Bool) { | ||
| 381 | + self.wjColorEndScrollOrEndDragging(scrollView) | ||
| 382 | + //外部代理 | ||
| 383 | + self.delegate?.customIndexViewDidEndDragging(scrollView: scrollView, decelerate: decelerate) | ||
| 384 | + } | ||
| 385 | + | ||
| 400 | ///WJColorChange 代理方法 滚动结束时候回调 | 386 | ///WJColorChange 代理方法 滚动结束时候回调 |
| 401 | func wjColorEndScroll(_ scrollView: UIScrollView!) { | 387 | func wjColorEndScroll(_ scrollView: UIScrollView!) { |
| 402 | - | ||
| 403 | - | 388 | + |
| 389 | + self.wjColorEndScrollOrEndDragging(scrollView) | ||
| 390 | + //外部代理 | ||
| 391 | + self.delegate?.customIndexViewDidEndScroll(scrollView: scrollView) | ||
| 392 | + } | ||
| 393 | + | ||
| 394 | + //公用方法 | ||
| 395 | + func wjColorEndScrollOrEndDragging(_ scrollView: UIScrollView!){ | ||
| 404 | let defaultOffset: CGFloat = self.frame.size.height | 396 | let defaultOffset: CGFloat = self.frame.size.height |
| 405 | 397 | ||
| 406 | let currentOffset: CGFloat = scrollView.contentOffset.y | 398 | let currentOffset: CGFloat = scrollView.contentOffset.y |
| @@ -440,9 +432,7 @@ class CNCustomIndexView:PGIndexBannerSubiew, UIScrollViewDelegate, WJColorChange | @@ -440,9 +432,7 @@ class CNCustomIndexView:PGIndexBannerSubiew, UIScrollViewDelegate, WJColorChange | ||
| 440 | 432 | ||
| 441 | //下滑提醒View回到初始位置 | 433 | //下滑提醒View回到初始位置 |
| 442 | self.downSlideViewRemindView.top = -(self.downSlideViewRemindView.height + 50) | 434 | self.downSlideViewRemindView.top = -(self.downSlideViewRemindView.height + 50) |
| 443 | - | ||
| 444 | - //外部代理 | ||
| 445 | - self.delegate?.customIndexViewDidEndScroll(scrollView: scrollView) | 435 | + |
| 446 | } | 436 | } |
| 447 | 437 | ||
| 448 | } | 438 | } |
metaCode/Classes/Vendors/WJColorChange.h
| @@ -15,6 +15,11 @@ | @@ -15,6 +15,11 @@ | ||
| 15 | @param scrollView 滚动视图 | 15 | @param scrollView 滚动视图 |
| 16 | */ | 16 | */ |
| 17 | - (void)WJColorScrollViewWillBeginDragging:(UIScrollView *)scrollView; | 17 | - (void)WJColorScrollViewWillBeginDragging:(UIScrollView *)scrollView; |
| 18 | +/** | ||
| 19 | + 结束拖拽 | ||
| 20 | + @param scrollView 滚动视图 | ||
| 21 | + */ | ||
| 22 | +- (void)WJColorScrollViewDidEndDragging:(UIScrollView *)scrollView decelerate:(BOOL)decelerate; | ||
| 18 | 23 | ||
| 19 | /** | 24 | /** |
| 20 | 滚动时候回调 传出当前的滚动视图 | 25 | 滚动时候回调 传出当前的滚动视图 |
metaCode/Classes/Vendors/WJColorChange.m
| @@ -201,7 +201,13 @@ | @@ -201,7 +201,13 @@ | ||
| 201 | } | 201 | } |
| 202 | 202 | ||
| 203 | } | 203 | } |
| 204 | +- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate | ||
| 205 | +{ | ||
| 206 | + if ([self.delegate respondsToSelector:@selector(WJColorScrollViewDidEndDragging:decelerate:)]) { | ||
| 207 | + [self.delegate WJColorScrollViewDidEndDragging:scrollView decelerate:decelerate]; | ||
| 208 | + } | ||
| 204 | 209 | ||
| 210 | +} | ||
| 205 | - (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView { | 211 | - (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView { |
| 206 | 212 | ||
| 207 | if ([self.delegate respondsToSelector:@selector(WJColorEndScroll:)]) { | 213 | if ([self.delegate respondsToSelector:@selector(WJColorEndScroll:)]) { |