Commit b617f1f76752521502c87f3476c1e753002babee
Merge branch 'master' of http://bj.gitlab.cnlive.com/ios-team/CNLiveMateCode
# Conflicts: # Podfile
Showing
9 changed files
with
252 additions
and
15 deletions
Podfile
| @@ -30,6 +30,8 @@ target 'metaCode' do | @@ -30,6 +30,8 @@ target 'metaCode' do | ||
| 30 | pod 'SwiftyUserDefaults' | 30 | pod 'SwiftyUserDefaults' |
| 31 | #图片视频选择器 | 31 | #图片视频选择器 |
| 32 | pod 'HXPHPicker' | 32 | pod 'HXPHPicker' |
| 33 | + #加载GIF | ||
| 34 | + pod 'SwiftGifOrigin', '~> 1.7.0' | ||
| 33 | 35 | ||
| 34 | target 'metaCodeTests' do | 36 | target 'metaCodeTests' do |
| 35 | inherit! :search_paths | 37 | inherit! :search_paths |
metaCode.xcodeproj/project.pbxproj
| @@ -49,6 +49,9 @@ | @@ -49,6 +49,9 @@ | ||
| 49 | 7C4931292A2D8BA8000E44B4 /* CNLiveBaseTabBarViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7C4931282A2D8BA8000E44B4 /* CNLiveBaseTabBarViewController.swift */; }; | 49 | 7C4931292A2D8BA8000E44B4 /* CNLiveBaseTabBarViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7C4931282A2D8BA8000E44B4 /* CNLiveBaseTabBarViewController.swift */; }; |
| 50 | 7C49312D2A2DB9FA000E44B4 /* UITabBar+CNBadge.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7C49312C2A2DB9FA000E44B4 /* UITabBar+CNBadge.swift */; }; | 50 | 7C49312D2A2DB9FA000E44B4 /* UITabBar+CNBadge.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7C49312C2A2DB9FA000E44B4 /* UITabBar+CNBadge.swift */; }; |
| 51 | 7C4931312A2F142F000E44B4 /* CNHomePageBackgroupView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7C4931302A2F142F000E44B4 /* CNHomePageBackgroupView.swift */; }; | 51 | 7C4931312A2F142F000E44B4 /* CNHomePageBackgroupView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7C4931302A2F142F000E44B4 /* CNHomePageBackgroupView.swift */; }; |
| 52 | + 7C4931342A307B58000E44B4 /* slide_down.gif in Resources */ = {isa = PBXBuildFile; fileRef = 7C4931332A307B58000E44B4 /* slide_down.gif */; }; | ||
| 53 | + 7C4931362A307B60000E44B4 /* slide_up.gif in Resources */ = {isa = PBXBuildFile; fileRef = 7C4931352A307B60000E44B4 /* slide_up.gif */; }; | ||
| 54 | + 7C4931382A307BDB000E44B4 /* CNHomePageGuideView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7C4931372A307BDB000E44B4 /* CNHomePageGuideView.swift */; }; | ||
| 52 | 7CD675292A270F6A008354C1 /* WJColorChange.m in Sources */ = {isa = PBXBuildFile; fileRef = 7CD675282A270F6A008354C1 /* WJColorChange.m */; }; | 55 | 7CD675292A270F6A008354C1 /* WJColorChange.m in Sources */ = {isa = PBXBuildFile; fileRef = 7CD675282A270F6A008354C1 /* WJColorChange.m */; }; |
| 53 | 7CD6753C2A2740B0008354C1 /* CNBottomPayMoneyRemindView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7CD675372A2740B0008354C1 /* CNBottomPayMoneyRemindView.swift */; }; | 56 | 7CD6753C2A2740B0008354C1 /* CNBottomPayMoneyRemindView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7CD675372A2740B0008354C1 /* CNBottomPayMoneyRemindView.swift */; }; |
| 54 | 7CD6753D2A2740B0008354C1 /* CNMainView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7CD675382A2740B0008354C1 /* CNMainView.swift */; }; | 57 | 7CD6753D2A2740B0008354C1 /* CNMainView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7CD675382A2740B0008354C1 /* CNMainView.swift */; }; |
| @@ -132,6 +135,9 @@ | @@ -132,6 +135,9 @@ | ||
| 132 | 7C4931282A2D8BA8000E44B4 /* CNLiveBaseTabBarViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNLiveBaseTabBarViewController.swift; sourceTree = "<group>"; }; | 135 | 7C4931282A2D8BA8000E44B4 /* CNLiveBaseTabBarViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNLiveBaseTabBarViewController.swift; sourceTree = "<group>"; }; |
| 133 | 7C49312C2A2DB9FA000E44B4 /* UITabBar+CNBadge.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UITabBar+CNBadge.swift"; sourceTree = "<group>"; }; | 136 | 7C49312C2A2DB9FA000E44B4 /* UITabBar+CNBadge.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UITabBar+CNBadge.swift"; sourceTree = "<group>"; }; |
| 134 | 7C4931302A2F142F000E44B4 /* CNHomePageBackgroupView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNHomePageBackgroupView.swift; sourceTree = "<group>"; }; | 137 | 7C4931302A2F142F000E44B4 /* CNHomePageBackgroupView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNHomePageBackgroupView.swift; sourceTree = "<group>"; }; |
| 138 | + 7C4931332A307B58000E44B4 /* slide_down.gif */ = {isa = PBXFileReference; lastKnownFileType = image.gif; path = slide_down.gif; sourceTree = "<group>"; }; | ||
| 139 | + 7C4931352A307B60000E44B4 /* slide_up.gif */ = {isa = PBXFileReference; lastKnownFileType = image.gif; path = slide_up.gif; sourceTree = "<group>"; }; | ||
| 140 | + 7C4931372A307BDB000E44B4 /* CNHomePageGuideView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNHomePageGuideView.swift; sourceTree = "<group>"; }; | ||
| 135 | 7CD675262A270F69008354C1 /* metaCode-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "metaCode-Bridging-Header.h"; sourceTree = "<group>"; }; | 141 | 7CD675262A270F69008354C1 /* metaCode-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "metaCode-Bridging-Header.h"; sourceTree = "<group>"; }; |
| 136 | 7CD675272A270F6A008354C1 /* WJColorChange.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WJColorChange.h; sourceTree = "<group>"; }; | 142 | 7CD675272A270F6A008354C1 /* WJColorChange.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WJColorChange.h; sourceTree = "<group>"; }; |
| 137 | 7CD675282A270F6A008354C1 /* WJColorChange.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WJColorChange.m; sourceTree = "<group>"; }; | 143 | 7CD675282A270F6A008354C1 /* WJColorChange.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WJColorChange.m; sourceTree = "<group>"; }; |
| @@ -313,6 +319,8 @@ | @@ -313,6 +319,8 @@ | ||
| 313 | isa = PBXGroup; | 319 | isa = PBXGroup; |
| 314 | children = ( | 320 | children = ( |
| 315 | 790D01A62A2DF84C00C5978D /* countries.plist */, | 321 | 790D01A62A2DF84C00C5978D /* countries.plist */, |
| 322 | + 7C4931332A307B58000E44B4 /* slide_down.gif */, | ||
| 323 | + 7C4931352A307B60000E44B4 /* slide_up.gif */, | ||
| 316 | ); | 324 | ); |
| 317 | path = Resources; | 325 | path = Resources; |
| 318 | sourceTree = "<group>"; | 326 | sourceTree = "<group>"; |
| @@ -428,6 +436,7 @@ | @@ -428,6 +436,7 @@ | ||
| 428 | 7CD6753A2A2740B0008354C1 /* CNTopCollectMoneyRemindView.swift */, | 436 | 7CD6753A2A2740B0008354C1 /* CNTopCollectMoneyRemindView.swift */, |
| 429 | 7CD675412A2740F8008354C1 /* CNCustomIndexView.swift */, | 437 | 7CD675412A2740F8008354C1 /* CNCustomIndexView.swift */, |
| 430 | 7C4931302A2F142F000E44B4 /* CNHomePageBackgroupView.swift */, | 438 | 7C4931302A2F142F000E44B4 /* CNHomePageBackgroupView.swift */, |
| 439 | + 7C4931372A307BDB000E44B4 /* CNHomePageGuideView.swift */, | ||
| 431 | ); | 440 | ); |
| 432 | name = View; | 441 | name = View; |
| 433 | path = HomePage/View; | 442 | path = HomePage/View; |
| @@ -622,7 +631,9 @@ | @@ -622,7 +631,9 @@ | ||
| 622 | 818163C82A25CFCF00579C86 /* LaunchScreen.storyboard in Resources */, | 631 | 818163C82A25CFCF00579C86 /* LaunchScreen.storyboard in Resources */, |
| 623 | 790D01A72A2DF84C00C5978D /* countries.plist in Resources */, | 632 | 790D01A72A2DF84C00C5978D /* countries.plist in Resources */, |
| 624 | 818163C52A25CFCF00579C86 /* Assets.xcassets in Resources */, | 633 | 818163C52A25CFCF00579C86 /* Assets.xcassets in Resources */, |
| 634 | + 7C4931342A307B58000E44B4 /* slide_down.gif in Resources */, | ||
| 625 | 818163C32A25CFCC00579C86 /* Main.storyboard in Resources */, | 635 | 818163C32A25CFCC00579C86 /* Main.storyboard in Resources */, |
| 636 | + 7C4931362A307B60000E44B4 /* slide_up.gif in Resources */, | ||
| 626 | ); | 637 | ); |
| 627 | runOnlyForDeploymentPostprocessing = 0; | 638 | runOnlyForDeploymentPostprocessing = 0; |
| 628 | }; | 639 | }; |
| @@ -767,6 +778,7 @@ | @@ -767,6 +778,7 @@ | ||
| 767 | 7CD6753D2A2740B0008354C1 /* CNMainView.swift in Sources */, | 778 | 7CD6753D2A2740B0008354C1 /* CNMainView.swift in Sources */, |
| 768 | 7CD675522A29C04B008354C1 /* CNLiveConstant.swift in Sources */, | 779 | 7CD675522A29C04B008354C1 /* CNLiveConstant.swift in Sources */, |
| 769 | 79282A402A2F055100B5F8CF /* CNLiveConfigUserInfo.swift in Sources */, | 780 | 79282A402A2F055100B5F8CF /* CNLiveConfigUserInfo.swift in Sources */, |
| 781 | + 7C4931382A307BDB000E44B4 /* CNHomePageGuideView.swift in Sources */, | ||
| 770 | 7CD6753E2A2740B0008354C1 /* CNPayMoneyCodeView.swift in Sources */, | 782 | 7CD6753E2A2740B0008354C1 /* CNPayMoneyCodeView.swift in Sources */, |
| 771 | 7CD675402A2740B0008354C1 /* CNCollectMoneyCodeView.swift in Sources */, | 783 | 7CD675402A2740B0008354C1 /* CNCollectMoneyCodeView.swift in Sources */, |
| 772 | 798A44FD2A309EBA00815935 /* CNLiveTypeFeedBackViewController.swift in Sources */, | 784 | 798A44FD2A309EBA00815935 /* CNLiveTypeFeedBackViewController.swift in Sources */, |
metaCode/Classes/Main/HomePage/Controller/CNMetaCodeHomePageController.swift
| @@ -8,12 +8,65 @@ | @@ -8,12 +8,65 @@ | ||
| 8 | import Foundation | 8 | import Foundation |
| 9 | import UIKit | 9 | import UIKit |
| 10 | import YYCategories | 10 | import YYCategories |
| 11 | +import SwiftGifOrigin | ||
| 11 | 12 | ||
| 12 | let Width: CGFloat = UIScreen.main.bounds.size.width | 13 | let Width: CGFloat = UIScreen.main.bounds.size.width |
| 13 | let Height: CGFloat = UIScreen.main.bounds.size.height | 14 | let Height: CGFloat = UIScreen.main.bounds.size.height |
| 14 | 15 | ||
| 16 | +///存储是否第一次显示首页上滑引导 | ||
| 17 | +let CNKeyIsFirstAppearUpSlideHomeGuide: String = "isFirstAppearUpSlideHomeGuideKey" | ||
| 18 | +///存储是否第一次显示首页下滑引导 | ||
| 19 | +let CNKeyIsFirstAppearDownSlideHomeGuide: String = "isFirstAppearDownSlideHomeGuideKey" | ||
| 20 | + | ||
| 15 | class CNMetaCodeHomePageController:CNLiveBaseViewController, NewPagedFlowViewDelegate, NewPagedFlowViewDataSource, CNCustomIndexViewDelegate{ | 21 | class CNMetaCodeHomePageController:CNLiveBaseViewController, NewPagedFlowViewDelegate, NewPagedFlowViewDataSource, CNCustomIndexViewDelegate{ |
| 16 | 22 | ||
| 23 | + ///上滑引导View | ||
| 24 | + lazy var upSlideGuideView:CNHomePageGuideView = { | ||
| 25 | + let upSlideGuideView = CNHomePageGuideView.init(frame: UIScreen.main.bounds) | ||
| 26 | + upSlideGuideView.setBottomText(text: "向上滑动") | ||
| 27 | + upSlideGuideView.skipAction = { | ||
| 28 | + [weak self] in | ||
| 29 | + self?.upSlideGuideView.removeFromSuperview() | ||
| 30 | + self?.upSlideGifView.removeFromSuperview() | ||
| 31 | + UserDefaults.standard.set("flase", forKey: CNKeyIsFirstAppearUpSlideHomeGuide) | ||
| 32 | + UserDefaults.standard.set("flase", forKey: CNKeyIsFirstAppearDownSlideHomeGuide) | ||
| 33 | + self?.pageFlowView.scrollView.isScrollEnabled = true | ||
| 34 | + } | ||
| 35 | + return upSlideGuideView | ||
| 36 | + }() | ||
| 37 | + ///上滑引导动图 | ||
| 38 | + lazy var upSlideGifView:UIImageView = { | ||
| 39 | + let gif: UIImageView = UIImageView(frame: CGRect(x: 200, y: 30, width: 40, height: 80)) | ||
| 40 | + gif.loadGif(name: "slide_up") | ||
| 41 | + gif.center = self.view.center | ||
| 42 | + gif.contentMode = .scaleAspectFill | ||
| 43 | + | ||
| 44 | + return gif | ||
| 45 | + }() | ||
| 46 | + | ||
| 47 | + ///下滑引导View | ||
| 48 | + lazy var downSlideGuideView:CNHomePageGuideView = { | ||
| 49 | + let downSlideGuideView = CNHomePageGuideView.init(frame: UIScreen.main.bounds) | ||
| 50 | + downSlideGuideView.setBottomText(text: "向下滑动") | ||
| 51 | + downSlideGuideView.skipAction = { | ||
| 52 | + [weak self ] in | ||
| 53 | + self?.downSlideGuideView.removeFromSuperview() | ||
| 54 | + self?.downSlideGifView.removeFromSuperview() | ||
| 55 | + UserDefaults.standard.set("flase", forKey: CNKeyIsFirstAppearDownSlideHomeGuide) | ||
| 56 | + self?.pageFlowView.scrollView.isScrollEnabled = true | ||
| 57 | + } | ||
| 58 | + return downSlideGuideView | ||
| 59 | + }() | ||
| 60 | + ///下滑引导动图 | ||
| 61 | + lazy var downSlideGifView:UIImageView = { | ||
| 62 | + let gif: UIImageView = UIImageView(frame: CGRect(x: 0, y: 0, width: 40, height: 80)) | ||
| 63 | + gif.center = self.view.center | ||
| 64 | + gif.loadGif(name: "slide_down") | ||
| 65 | + gif.contentMode = .scaleAspectFill | ||
| 66 | + return gif | ||
| 67 | + }() | ||
| 68 | + | ||
| 69 | + | ||
| 17 | ///NewPagedFlowView 开始滑动时的偏移量 | 70 | ///NewPagedFlowView 开始滑动时的偏移量 |
| 18 | private var beginOffset = 0.0 | 71 | private var beginOffset = 0.0 |
| 19 | 72 | ||
| @@ -66,6 +119,7 @@ class CNMetaCodeHomePageController:CNLiveBaseViewController, NewPagedFlowViewDel | @@ -66,6 +119,7 @@ class CNMetaCodeHomePageController:CNLiveBaseViewController, NewPagedFlowViewDel | ||
| 66 | 119 | ||
| 67 | // self.tabBarController?.tabBar.top = self.tabBarY + KSreenHeight | 120 | // self.tabBarController?.tabBar.top = self.tabBarY + KSreenHeight |
| 68 | 121 | ||
| 122 | + | ||
| 69 | } | 123 | } |
| 70 | override func viewWillAppear(_ animated: Bool) { | 124 | override func viewWillAppear(_ animated: Bool) { |
| 71 | super.viewWillAppear(animated) | 125 | super.viewWillAppear(animated) |
| @@ -74,7 +128,29 @@ class CNMetaCodeHomePageController:CNLiveBaseViewController, NewPagedFlowViewDel | @@ -74,7 +128,29 @@ class CNMetaCodeHomePageController:CNLiveBaseViewController, NewPagedFlowViewDel | ||
| 74 | super.viewDidAppear(animated) | 128 | super.viewDidAppear(animated) |
| 75 | self.view.height = KSreenHeight | 129 | self.view.height = KSreenHeight |
| 76 | 130 | ||
| 131 | + self.topNavView.isHidden = true | ||
| 132 | + | ||
| 77 | 133 | ||
| 134 | +// | ||
| 135 | +// | ||
| 136 | +// let maskView = UIView.init(frame: UIScreen.main.bounds) | ||
| 137 | +// maskView.backgroundColor = .black.withAlphaComponent(0.7) | ||
| 138 | +// maskView.isUserInteractionEnabled = false | ||
| 139 | +// | ||
| 140 | +// let path:UIBezierPath = UIBezierPath.init(rect: UIScreen.main.bounds) | ||
| 141 | +// | ||
| 142 | +// let W = KSreenWidth-50 | ||
| 143 | +// let H = W*1.5 | ||
| 144 | +// let rect = CGRectMake(25, (KSreenHeight-H)/2,W, H) | ||
| 145 | +// | ||
| 146 | +// let appendPath: UIBezierPath = UIBezierPath.init(roundedRect: rect, cornerRadius: 20) | ||
| 147 | +// path.append(appendPath.reversing()) | ||
| 148 | +// let shapeLayer: CAShapeLayer = CAShapeLayer() | ||
| 149 | +// shapeLayer.path = path.cgPath; | ||
| 150 | +// maskView.layer.mask = shapeLayer; | ||
| 151 | +// | ||
| 152 | +// self.view.addSubview(maskView) | ||
| 153 | + | ||
| 78 | } | 154 | } |
| 79 | // MARK: - 添加UI | 155 | // MARK: - 添加UI |
| 80 | func setupUI(){ | 156 | func setupUI(){ |
| @@ -83,6 +159,30 @@ class CNMetaCodeHomePageController:CNLiveBaseViewController, NewPagedFlowViewDel | @@ -83,6 +159,30 @@ class CNMetaCodeHomePageController:CNLiveBaseViewController, NewPagedFlowViewDel | ||
| 83 | self.view.addSubview(self.pageFlowView) | 159 | self.view.addSubview(self.pageFlowView) |
| 84 | self.pageFlowView.reloadData() | 160 | self.pageFlowView.reloadData() |
| 85 | 161 | ||
| 162 | + //首选判断是否显示了上滑引导 | ||
| 163 | + let isFirstAppearUpSlideHomeGuide:Any? = UserDefaults.standard.object(forKey: CNKeyIsFirstAppearUpSlideHomeGuide) | ||
| 164 | + | ||
| 165 | + if let tempGuide = isFirstAppearUpSlideHomeGuide{ | ||
| 166 | + //已经显示过上滑引导 | ||
| 167 | + | ||
| 168 | + //判断是否显示过下滑引导 | ||
| 169 | + let isFirstAppearDownSlideHomeGuide:Any? = UserDefaults.standard.object(forKey: CNKeyIsFirstAppearDownSlideHomeGuide) | ||
| 170 | + if let tempDownGuide = isFirstAppearDownSlideHomeGuide{ | ||
| 171 | + | ||
| 172 | + }else{ | ||
| 173 | + //没有显示下滑引导 | ||
| 174 | + self.pageFlowView.scrollView.isScrollEnabled = false | ||
| 175 | + self.view.addSubview(self.downSlideGuideView) | ||
| 176 | + self.view.addSubview(self.downSlideGifView) | ||
| 177 | + } | ||
| 178 | + | ||
| 179 | + }else{ | ||
| 180 | + //没显示过上滑引导 | ||
| 181 | + self.pageFlowView.scrollView.isScrollEnabled = false | ||
| 182 | + self.view.addSubview(self.upSlideGuideView) | ||
| 183 | + self.view.addSubview(self.upSlideGifView) | ||
| 184 | + } | ||
| 185 | + | ||
| 86 | } | 186 | } |
| 87 | 187 | ||
| 88 | // MARK: - NewPagedFlowView代理 | 188 | // MARK: - NewPagedFlowView代理 |
| @@ -147,16 +247,19 @@ class CNMetaCodeHomePageController:CNLiveBaseViewController, NewPagedFlowViewDel | @@ -147,16 +247,19 @@ class CNMetaCodeHomePageController:CNLiveBaseViewController, NewPagedFlowViewDel | ||
| 147 | } | 247 | } |
| 148 | } | 248 | } |
| 149 | } | 249 | } |
| 150 | - | ||
| 151 | ///NewPagedFlowView 滑动将要结束 | 250 | ///NewPagedFlowView 滑动将要结束 |
| 152 | - func willEndScroll(_ scrollView: UIScrollView!) { | 251 | + func willEndScroll(_ scrollView: UIScrollView!, willDecelerate decelerate: Bool) { |
| 153 | 252 | ||
| 154 | //暂时禁止再次滑动,后期优化通过自定义UIScrollView 结束动画来实现 | 253 | //暂时禁止再次滑动,后期优化通过自定义UIScrollView 结束动画来实现 |
| 155 | - scrollView.isScrollEnabled = false | 254 | + if(decelerate == true){ |
| 255 | + scrollView.isScrollEnabled = false | ||
| 256 | + } | ||
| 156 | } | 257 | } |
| 157 | ///NewPagedFlowView 滑动结束 | 258 | ///NewPagedFlowView 滑动结束 |
| 158 | func didEndScroll(_ scrollView: UIScrollView!) { | 259 | func didEndScroll(_ scrollView: UIScrollView!) { |
| 159 | - print("scrollView.contentOffset.x = ",scrollView.contentOffset.x) | 260 | + |
| 261 | + scrollView.isScrollEnabled = true | ||
| 262 | + | ||
| 160 | let toIndex:Int = Int(scrollView.contentOffset.x/(Width-50)) | 263 | let toIndex:Int = Int(scrollView.contentOffset.x/(Width-50)) |
| 161 | 264 | ||
| 162 | if toIndex == self.backgroupView.currentApearViewIndex{ | 265 | if toIndex == self.backgroupView.currentApearViewIndex{ |
| @@ -165,8 +268,6 @@ class CNMetaCodeHomePageController:CNLiveBaseViewController, NewPagedFlowViewDel | @@ -165,8 +268,6 @@ class CNMetaCodeHomePageController:CNLiveBaseViewController, NewPagedFlowViewDel | ||
| 165 | 268 | ||
| 166 | self.backgroupView.replaceCurerrentApearView(fromIndex: self.backgroupView.currentApearViewIndex, toIndex: toIndex) | 269 | self.backgroupView.replaceCurerrentApearView(fromIndex: self.backgroupView.currentApearViewIndex, toIndex: toIndex) |
| 167 | 270 | ||
| 168 | - scrollView.isScrollEnabled = true | ||
| 169 | - | ||
| 170 | } | 271 | } |
| 171 | 272 | ||
| 172 | 273 | ||
| @@ -174,6 +275,25 @@ class CNMetaCodeHomePageController:CNLiveBaseViewController, NewPagedFlowViewDel | @@ -174,6 +275,25 @@ class CNMetaCodeHomePageController:CNLiveBaseViewController, NewPagedFlowViewDel | ||
| 174 | 275 | ||
| 175 | func customIndexViewWillBeiginScroll(scrollView: UIScrollView) { | 276 | func customIndexViewWillBeiginScroll(scrollView: UIScrollView) { |
| 176 | self.view.height = KSreenHeight | 277 | self.view.height = KSreenHeight |
| 278 | + | ||
| 279 | + /**开始拖拽移除引导View**/ | ||
| 280 | + | ||
| 281 | + //移除上滑引导 | ||
| 282 | + if(self.upSlideGuideView.superview != nil){ | ||
| 283 | + self.upSlideGuideView.removeFromSuperview() | ||
| 284 | + self.upSlideGifView.removeFromSuperview() | ||
| 285 | + UserDefaults.standard.set("flase", forKey: CNKeyIsFirstAppearUpSlideHomeGuide) | ||
| 286 | + } | ||
| 287 | + | ||
| 288 | + //移除下滑引导 | ||
| 289 | + if (self.downSlideGuideView.superview != nil) { | ||
| 290 | + self.downSlideGuideView.removeFromSuperview() | ||
| 291 | + self.downSlideGifView.removeFromSuperview() | ||
| 292 | + UserDefaults.standard.set("flase", forKey: CNKeyIsFirstAppearDownSlideHomeGuide) | ||
| 293 | + self.pageFlowView.scrollView.isScrollEnabled = true | ||
| 294 | + } | ||
| 295 | + | ||
| 296 | + | ||
| 177 | } | 297 | } |
| 178 | func customIndexViewDidScroll(scrollView: UIScrollView) { | 298 | func customIndexViewDidScroll(scrollView: UIScrollView) { |
| 179 | //让tabbar跟随scrollView平移量进行移动 | 299 | //让tabbar跟随scrollView平移量进行移动 |
| @@ -188,6 +308,17 @@ class CNMetaCodeHomePageController:CNLiveBaseViewController, NewPagedFlowViewDel | @@ -188,6 +308,17 @@ class CNMetaCodeHomePageController:CNLiveBaseViewController, NewPagedFlowViewDel | ||
| 188 | func customIndexViewDidEndScroll(scrollView: UIScrollView) { | 308 | func customIndexViewDidEndScroll(scrollView: UIScrollView) { |
| 189 | if scrollView.contentOffset.y == KSreenHeight { | 309 | if scrollView.contentOffset.y == KSreenHeight { |
| 190 | self.view.height = self.tabBarY | 310 | self.view.height = self.tabBarY |
| 311 | + | ||
| 312 | + //判断是否显示过下滑引导 | ||
| 313 | + let isFirstAppearDownSlideHomeGuide:Any? = UserDefaults.standard.object(forKey: CNKeyIsFirstAppearDownSlideHomeGuide) | ||
| 314 | + if let tempDownGuide = isFirstAppearDownSlideHomeGuide{ | ||
| 315 | + print("不该进来") | ||
| 316 | + }else{ | ||
| 317 | + //没有显示下滑引导 | ||
| 318 | + self.view.addSubview(self.downSlideGuideView) | ||
| 319 | + self.view.addSubview(self.downSlideGifView) | ||
| 320 | + self.pageFlowView.scrollView.isScrollEnabled = false | ||
| 321 | + } | ||
| 191 | } | 322 | } |
| 192 | } | 323 | } |
| 193 | 324 |
metaCode/Classes/Main/HomePage/View/CNCustomIndexView.swift
| @@ -131,8 +131,8 @@ class CNCustomIndexView:PGIndexBannerSubiew, UIScrollViewDelegate, WJColorChange | @@ -131,8 +131,8 @@ class CNCustomIndexView:PGIndexBannerSubiew, UIScrollViewDelegate, WJColorChange | ||
| 131 | ///中间主界面 | 131 | ///中间主界面 |
| 132 | lazy var mainView:CNMainView = { | 132 | lazy var mainView:CNMainView = { |
| 133 | let W = self.width | 133 | let W = self.width |
| 134 | - let H = W*1.5 | ||
| 135 | - let mainView = CNMainView.init(frame: CGRectMake(0, self.frame.size.height + (self.frame.size.height-H)/2,W, H)) | 134 | + let H = W*1.5 |
| 135 | + let mainView = CNMainView.init(frame: CGRectMake(0, self.frame.size.height + KSreenHeight*0.16,W, H)) | ||
| 136 | return mainView | 136 | return mainView |
| 137 | }() | 137 | }() |
| 138 | 138 | ||
| @@ -141,6 +141,7 @@ class CNCustomIndexView:PGIndexBannerSubiew, UIScrollViewDelegate, WJColorChange | @@ -141,6 +141,7 @@ class CNCustomIndexView:PGIndexBannerSubiew, UIScrollViewDelegate, WJColorChange | ||
| 141 | let collectionView = CNCollectMoneyCodeView.init(frame: CGRectMake(-25, 0, self.frame.size.width + 50, self.frame.size.height)) | 141 | let collectionView = CNCollectMoneyCodeView.init(frame: CGRectMake(-25, 0, self.frame.size.width + 50, self.frame.size.height)) |
| 142 | collectionView.backAction = {[weak self] in | 142 | collectionView.backAction = {[weak self] in |
| 143 | self?.baseScrollView.setContentOffset(CGPoint(x: 0, y: (self!.baseScrollView.height)), animated: true) | 143 | self?.baseScrollView.setContentOffset(CGPoint(x: 0, y: (self!.baseScrollView.height)), animated: true) |
| 144 | + self?.superScrollView?.isScrollEnabled = true | ||
| 144 | } | 145 | } |
| 145 | return collectionView | 146 | return collectionView |
| 146 | }() | 147 | }() |
| @@ -357,16 +358,15 @@ class CNCustomIndexView:PGIndexBannerSubiew, UIScrollViewDelegate, WJColorChange | @@ -357,16 +358,15 @@ class CNCustomIndexView:PGIndexBannerSubiew, UIScrollViewDelegate, WJColorChange | ||
| 357 | self.collectMoneyCodeView.contentView.backgroundColor = KVCBackgroupColor | 358 | self.collectMoneyCodeView.contentView.backgroundColor = KVCBackgroupColor |
| 358 | } | 359 | } |
| 359 | 360 | ||
| 360 | - //外部代理 | ||
| 361 | - self.delegate?.customIndexViewDidEndScroll(scrollView: scrollView) | ||
| 362 | - | ||
| 363 | - | ||
| 364 | 361 | ||
| 365 | //滑动结束 把topNavView 放到scrollView的上层 | 362 | //滑动结束 把topNavView 放到scrollView的上层 |
| 366 | self.bringSubviewToFront(self.topNavView) | 363 | self.bringSubviewToFront(self.topNavView) |
| 367 | 364 | ||
| 368 | //下滑提醒View回到初始位置 | 365 | //下滑提醒View回到初始位置 |
| 369 | self.topCollectMoneyRemindView.top = -(self.topCollectMoneyRemindView.height + 50) | 366 | self.topCollectMoneyRemindView.top = -(self.topCollectMoneyRemindView.height + 50) |
| 367 | + | ||
| 368 | + //外部代理 | ||
| 369 | + self.delegate?.customIndexViewDidEndScroll(scrollView: scrollView) | ||
| 370 | } | 370 | } |
| 371 | 371 | ||
| 372 | } | 372 | } |
metaCode/Classes/Main/HomePage/View/CNHomePageGuideView.swift
0 → 100644
| 1 | +// | ||
| 2 | +// CNHomePageGuideView.swift | ||
| 3 | +// metaCode | ||
| 4 | +// | ||
| 5 | +// Created by daojian on 2023/6/7. | ||
| 6 | +// 首页引导 | ||
| 7 | + | ||
| 8 | +import Foundation | ||
| 9 | + | ||
| 10 | +typealias skipGuideBlock = ()->Void | ||
| 11 | + | ||
| 12 | +class CNHomePageGuideView: UIView{ | ||
| 13 | + ///跳过引导事件回调 | ||
| 14 | + var skipAction: skipGuideBlock? | ||
| 15 | + | ||
| 16 | + lazy var skipButtom: UIButton = { | ||
| 17 | + | ||
| 18 | + let skipButtom = UIButton(type: .custom) | ||
| 19 | + skipButtom.frame = CGRect(x: 0, y: 0, width: 90, height: 30) | ||
| 20 | + skipButtom.right = self.width - 30 | ||
| 21 | + skipButtom.top = KStatusBarHeight + 30 | ||
| 22 | + skipButtom.setTitle("跳过引导", for: .normal) | ||
| 23 | + skipButtom.setTitleColor(.white, for: .normal) | ||
| 24 | + skipButtom.titleLabel?.font = UIFont.systemFont(ofSize: 13, weight: .medium) | ||
| 25 | + skipButtom.clipsToBounds = true | ||
| 26 | + skipButtom.layer.cornerRadius = skipButtom.height/2 | ||
| 27 | + skipButtom.layer.borderColor = UIColor("#979797")?.cgColor | ||
| 28 | + skipButtom.layer.borderWidth = 0.5 | ||
| 29 | + | ||
| 30 | + return skipButtom | ||
| 31 | + | ||
| 32 | + }() | ||
| 33 | + | ||
| 34 | + lazy var bottomLabel: UILabel = { | ||
| 35 | + let bottomLabel = UILabel.init(frame: CGRect(x: 0, y: 0, width: 150, height: 20)) | ||
| 36 | + bottomLabel.textColor = .white | ||
| 37 | + bottomLabel.font = UIFont.systemFont(ofSize: 18, weight: .medium) | ||
| 38 | + bottomLabel.textAlignment = .center | ||
| 39 | + return bottomLabel | ||
| 40 | + }() | ||
| 41 | + | ||
| 42 | + override init(frame: CGRect) { | ||
| 43 | + super.init(frame: frame) | ||
| 44 | + self.initUI() | ||
| 45 | + } | ||
| 46 | + | ||
| 47 | + required init?(coder: NSCoder) { | ||
| 48 | + fatalError("init(coder:) has not been implemented") | ||
| 49 | + } | ||
| 50 | + func initUI(){ | ||
| 51 | + | ||
| 52 | + self.addSubview(self.skipButtom) | ||
| 53 | + | ||
| 54 | + self.backgroundColor = .black.withAlphaComponent(0.7) | ||
| 55 | + self.isUserInteractionEnabled = false | ||
| 56 | + | ||
| 57 | + //通过设置mask透明区域来实现镂空效果 | ||
| 58 | + let path:UIBezierPath = UIBezierPath.init(rect: UIScreen.main.bounds) | ||
| 59 | + | ||
| 60 | + //rect 首页被镂空的区域 | ||
| 61 | + let W = KSreenWidth-50 | ||
| 62 | + let H = W*1.5 | ||
| 63 | + let rect = CGRectMake(25, KSreenHeight*0.16,W, H) | ||
| 64 | + | ||
| 65 | + let appendPath: UIBezierPath = UIBezierPath.init(roundedRect: rect, cornerRadius: 20) | ||
| 66 | + path.append(appendPath.reversing()) | ||
| 67 | + | ||
| 68 | + let shapeLayer: CAShapeLayer = CAShapeLayer() | ||
| 69 | + shapeLayer.path = path.cgPath; | ||
| 70 | + self.layer.mask = shapeLayer | ||
| 71 | + | ||
| 72 | + //更新bottomLabel位置 | ||
| 73 | + self.bottomLabel.centerX = self.centerX | ||
| 74 | + self.bottomLabel.top = CGRectGetMaxY(rect) + 20 | ||
| 75 | + self.addSubview(self.bottomLabel) | ||
| 76 | + } | ||
| 77 | + | ||
| 78 | + override func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? { | ||
| 79 | + | ||
| 80 | + if((self.skipButtom.layer.hitTest(point)) != nil){ | ||
| 81 | +// print("点击了跳过") | ||
| 82 | + self.skipAction!() | ||
| 83 | + } | ||
| 84 | + //让事件响应链进行执行 | ||
| 85 | + return super.hitTest(point, with: event) | ||
| 86 | + } | ||
| 87 | + | ||
| 88 | + func setBottomText(text: String)->Void{ | ||
| 89 | + self.bottomLabel.text = text | ||
| 90 | + } | ||
| 91 | +} |
metaCode/Classes/Resources/slide_down.gif
0 → 100644
46.4 KB
metaCode/Classes/Resources/slide_up.gif
0 → 100644
46.8 KB
metaCode/Classes/Vendors/NewPagedFlowView.h
| @@ -185,7 +185,7 @@ typedef NS_ENUM (NSUInteger, NewPagedFlowViewOrientation) { | @@ -185,7 +185,7 @@ typedef NS_ENUM (NSUInteger, NewPagedFlowViewOrientation) { | ||
| 185 | 185 | ||
| 186 | /// 将要结束滚动 | 186 | /// 将要结束滚动 |
| 187 | /// @param scrollView 滚动的scrollView | 187 | /// @param scrollView 滚动的scrollView |
| 188 | -- (void)willEndScroll:(UIScrollView *)scrollView; | 188 | +- (void)willEndScroll:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate; |
| 189 | 189 | ||
| 190 | /// 已经结束滚动 | 190 | /// 已经结束滚动 |
| 191 | /// @param scrollView 滚动的scrollView | 191 | /// @param scrollView 滚动的scrollView |
metaCode/Classes/Vendors/NewPagedFlowView.m
| @@ -672,8 +672,9 @@ static NSString *subviewClassName; | @@ -672,8 +672,9 @@ static NSString *subviewClassName; | ||
| 672 | #pragma mark --结束拖拽 | 672 | #pragma mark --结束拖拽 |
| 673 | - (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate { | 673 | - (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate { |
| 674 | [self startTimer]; | 674 | [self startTimer]; |
| 675 | - if(self.delegate && [self.delegate respondsToSelector:@selector(willEndScroll:)]){ | ||
| 676 | - [self.delegate willEndScroll:scrollView]; | 675 | + |
| 676 | + if(self.delegate && [self.delegate respondsToSelector:@selector(willEndScroll: willDecelerate:)]){ | ||
| 677 | + [self.delegate willEndScroll:scrollView willDecelerate:decelerate]; | ||
| 677 | } | 678 | } |
| 678 | } | 679 | } |
| 679 | //结束滑动 | 680 | //结束滑动 |