Commit a64e13efa3b2bf8f75424164e81f9f727ccfe125

Authored by niudaojian
1 parent accc5f8b

添加首页背景图,回到首页

Showing 26 changed files with 361 additions and 80 deletions
metaCode.xcodeproj/project.pbxproj
... ... @@ -26,6 +26,7 @@
26 26 79A68C4C2A26EA6000DC3B43 /* (null) in Sources */ = {isa = PBXBuildFile; };
27 27 7C4931292A2D8BA8000E44B4 /* CNLiveBaseTabBarViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7C4931282A2D8BA8000E44B4 /* CNLiveBaseTabBarViewController.swift */; };
28 28 7C49312D2A2DB9FA000E44B4 /* UITabBar+CNBadge.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7C49312C2A2DB9FA000E44B4 /* UITabBar+CNBadge.swift */; };
  29 + 7C4931312A2F142F000E44B4 /* CNHomePageBackgroupView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7C4931302A2F142F000E44B4 /* CNHomePageBackgroupView.swift */; };
29 30 7CD675292A270F6A008354C1 /* WJColorChange.m in Sources */ = {isa = PBXBuildFile; fileRef = 7CD675282A270F6A008354C1 /* WJColorChange.m */; };
30 31 7CD6753C2A2740B0008354C1 /* CNBottomPayMoneyRemindView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7CD675372A2740B0008354C1 /* CNBottomPayMoneyRemindView.swift */; };
31 32 7CD6753D2A2740B0008354C1 /* CNMainView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7CD675382A2740B0008354C1 /* CNMainView.swift */; };
... ... @@ -86,6 +87,7 @@
86 87 79A68C512A26F59C00DC3B43 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = metaCode/Info.plist; sourceTree = "<group>"; };
87 88 7C4931282A2D8BA8000E44B4 /* CNLiveBaseTabBarViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNLiveBaseTabBarViewController.swift; sourceTree = "<group>"; };
88 89 7C49312C2A2DB9FA000E44B4 /* UITabBar+CNBadge.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UITabBar+CNBadge.swift"; sourceTree = "<group>"; };
  90 + 7C4931302A2F142F000E44B4 /* CNHomePageBackgroupView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNHomePageBackgroupView.swift; sourceTree = "<group>"; };
89 91 7CD675262A270F69008354C1 /* metaCode-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "metaCode-Bridging-Header.h"; sourceTree = "<group>"; };
90 92 7CD675272A270F6A008354C1 /* WJColorChange.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WJColorChange.h; sourceTree = "<group>"; };
91 93 7CD675282A270F6A008354C1 /* WJColorChange.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WJColorChange.m; sourceTree = "<group>"; };
... ... @@ -335,6 +337,7 @@
335 337 7CD675392A2740B0008354C1 /* CNPayMoneyCodeView.swift */,
336 338 7CD6753A2A2740B0008354C1 /* CNTopCollectMoneyRemindView.swift */,
337 339 7CD675412A2740F8008354C1 /* CNCustomIndexView.swift */,
  340 + 7C4931302A2F142F000E44B4 /* CNHomePageBackgroupView.swift */,
338 341 );
339 342 name = View;
340 343 path = HomePage/View;
... ... @@ -675,6 +678,7 @@
675 678 790D01A32A2DDBA300C5978D /* CNLiveConfigManager.swift in Sources */,
676 679 79A68C4A2A26E6CE00DC3B43 /* (null) in Sources */,
677 680 790D01852A2D89E100C5978D /* UIColor+CNHexColor.swift in Sources */,
  681 + 7C4931312A2F142F000E44B4 /* CNHomePageBackgroupView.swift in Sources */,
678 682 790D018B2A2D8B3300C5978D /* CNLiveLoginViewController.swift in Sources */,
679 683 7CD675422A2740F8008354C1 /* CNCustomIndexView.swift in Sources */,
680 684 790D01912A2DAC5E00C5978D /* CNLiveConfigFontMacro.swift in Sources */,
... ...
metaCode/Classes/Constant/CNLiveConstant.swift
... ... @@ -13,11 +13,11 @@ let KSreenWidth = UIScreen.main.bounds.width
13 13 let KSreenHeight = UIScreen.main.bounds.height
14 14  
15 15 ///状态栏高度
16   -let KStatusBarHeight = UIApplication.shared.statusBarFrame.height;
  16 +let KStatusBarHeight:CGFloat = UIApplication.shared.statusBarFrame.height;
17 17 ///导航栏高度
18   -let KNavigationHeight = (KStatusBarHeight + 44)
  18 +let KNavigationHeight:CGFloat = (KStatusBarHeight + 44)
19 19 ///tabbar高度
20   -let KTabBarHeight = (KStatusBarHeight == 44 ? 83 : 49)
  20 +let KTabBarHeight:CGFloat = (KStatusBarHeight == 44 ? 83 : 49)
21 21  
22 22 //MARK: - 常用背景色
23 23 ///控制器背景色
... ...
metaCode/Classes/Main/HomePage/Controller/CNMetaCodeHomePageController.swift
... ... @@ -27,23 +27,29 @@ class CNMetaCodeHomePageController:CNLiveBaseViewController, NewPagedFlowViewDel
27 27  
28 28 ///左右滑动分页view
29 29 lazy var pageFlowView: NewPagedFlowView = {
30   - let pageFlowView = NewPagedFlowView.init(frame: CGRectMake(0, 0, Width, Height));
  30 + let pageFlowView = NewPagedFlowView.init(frame: CGRectMake(0, 0, Width, Height))
31 31  
32   - pageFlowView.delegate = self;
33   - pageFlowView.dataSource = self;
34   - pageFlowView.minimumPageAlpha = 0.1;
35   - pageFlowView.isCarousel = false;
36   - pageFlowView.orientation = .horizontal;
37   - pageFlowView.leftRightMargin = 20;
38   - pageFlowView.isOpenAutoScroll = false;
  32 + pageFlowView.delegate = self
  33 + pageFlowView.dataSource = self
  34 + pageFlowView.minimumPageAlpha = 0.1
  35 + pageFlowView.isCarousel = false
  36 + pageFlowView.orientation = .horizontal
  37 + pageFlowView.leftRightMargin = 20
  38 + pageFlowView.isOpenAutoScroll = false
39 39  
40 40 //左右图片的距离顶部和底部的高度
41   - pageFlowView.topBottomMargin = 100;
  41 + pageFlowView.topBottomMargin = 100
42 42  
43 43 return pageFlowView
44 44  
45 45 }()
46 46  
  47 + ///背景
  48 + var backgroupView: CNHomePageBackgroupView = {
  49 + let backgroupView = CNHomePageBackgroupView.init(frame: CGRect(x: 0, y: 0, width: KSreenWidth, height: KSreenWidth*1.333))
  50 + return backgroupView
  51 + }()
  52 +
47 53 //MARK: 生命周期方法
48 54 override func viewDidLoad() {
49 55 super.viewDidLoad()
... ... @@ -51,7 +57,7 @@ class CNMetaCodeHomePageController:CNLiveBaseViewController, NewPagedFlowViewDel
51 57 self.tabBarY = (self.tabBarController?.tabBar.top)!
52 58  
53 59  
54   - for i in (0..<2) {
  60 + for i in (0..<6) {
55 61 self.dataArray.add("122")
56 62 }
57 63  
... ... @@ -72,6 +78,7 @@ class CNMetaCodeHomePageController:CNLiveBaseViewController, NewPagedFlowViewDel
72 78 // MARK: - 添加UI
73 79 func setupUI(){
74 80 self.view.backgroundColor = KVCBackgroupColor
  81 + self.view.addSubview(self.backgroupView)
75 82 self.view.addSubview(self.pageFlowView)
76 83 self.pageFlowView.reloadData()
77 84  
... ... @@ -84,18 +91,18 @@ class CNMetaCodeHomePageController:CNLiveBaseViewController, NewPagedFlowViewDel
84 91 }
85 92  
86 93 func flowView(_ flowView: NewPagedFlowView!, cellForPageAt index: Int) -> PGIndexBannerSubiew! {
87   - var bannerView:CNCustomIndexView? = flowView.dequeueReusableCell() as? CNCustomIndexView;
  94 + var bannerView:CNCustomIndexView? = flowView.dequeueReusableCell() as? CNCustomIndexView
88 95  
89 96 if (bannerView == nil) {
90   - bannerView = CNCustomIndexView.init(frame: CGRectMake(0, 0, Width-50, Height));
91   - bannerView?.tag = index + 100;
92   - bannerView?.layer.cornerRadius = 4;
93   - bannerView?.layer.masksToBounds = false;
  97 + bannerView = CNCustomIndexView.init(frame: CGRectMake(0, 0, Width-50, Height))
  98 + bannerView?.tag = index + 100
  99 + bannerView?.layer.cornerRadius = 4
  100 + bannerView?.layer.masksToBounds = false
94 101 }
95   - bannerView?.superScrollView = flowView.scrollView;
96   - bannerView?.associatedVCView = self.view;
  102 + bannerView?.superScrollView = flowView.scrollView
  103 + bannerView?.associatedVCView = self.view
97 104 bannerView?.delegate = self
98   - return bannerView;
  105 + return bannerView
99 106 }
100 107  
101 108 func sizeForPage(in flowView: NewPagedFlowView!) -> CGSize {
... ... @@ -107,11 +114,12 @@ class CNMetaCodeHomePageController:CNLiveBaseViewController, NewPagedFlowViewDel
107 114 self.view.height = KSreenHeight
108 115 }
109 116 func customIndexViewDidScroll(scrollView: UIScrollView) {
  117 + //让tabbar跟随scrollView平移量进行移动
110 118 let fabsOffset: CGFloat = abs(scrollView.contentOffset.y - KSreenHeight)
111 119 self.tabBarController?.tabBar.top = self.tabBarY + fabsOffset
112   -// print("view 的frame ",self.view.frame)
113   -
114 120  
  121 + //让背景view也跟随scrollView平移量的3倍速进行移动
  122 + self.backgroupView.top = -fabsOffset*3
115 123 }
116 124  
117 125  
... ...
metaCode/Classes/Main/HomePage/View/CNBottomPayMoneyRemindView.swift
... ... @@ -27,13 +27,17 @@ class CNBottomPayMoneyRemindView:UIView{
27 27  
28 28 let bottomShapeLayer = CAShapeLayer()
29 29 bottomShapeLayer.path = bottomCircle.cgPath
30   - bottomShapeLayer.fillColor = UIColor("#FCE0E0")?.cgColor
  30 + bottomShapeLayer.fillColor = UIColor("#F0F5FD")?.cgColor
31 31 self.layer.addSublayer(bottomShapeLayer)
32 32  
  33 + let imageView:UIImageView = UIImageView.init(image: UIImage(named: "homePage_up_icon"))
  34 + imageView.frame = CGRect(x: (self.width - 15)/2, y: 19, width: 15, height: 15)
  35 + self.addSubview(imageView)
  36 +
33 37 let btn = UIButton(type: .custom)
34   - btn.frame = CGRect(x: (self.width - 50)/2, y: 20, width: 50, height: 50)
35   - btn.setTitle("付钱", for: .normal)
36   - btn.setTitleColor(UIColor.red, for: .normal)
  38 + btn.frame = CGRect(x: (self.width - 50)/2, y: imageView.bottom, width: 50, height: 25)
  39 + btn.setTitle("上滑", for: .normal)
  40 + btn.setTitleColor(UIColor("#004FE0"), for: .normal)
37 41 btn.titleLabel?.font = UIFont(name: "KohinoorTelugu-Regular", size: 17)
38 42 btn.isUserInteractionEnabled = false
39 43  
... ...
metaCode/Classes/Main/HomePage/View/CNCollectMoneyCodeView.swift
... ... @@ -9,25 +9,29 @@ import Foundation
9 9 import UIKit
10 10 import YYCategories
11 11  
  12 +typealias backBlock = ()->Void;
  13 +
12 14 ///收钱码View
13 15 class CNCollectMoneyCodeView:UIView{
  16 + //返回首页
  17 + var backAction:backBlock?
14 18  
15   - ///懒加载
  19 + //MARK: - 懒加载
16 20 lazy var contentView:UIView = {
17 21  
18   - let contentView = UIView.init(frame: CGRect(x: 0, y: 0, width: self.width, height: self.height-150))
19   - contentView.backgroundColor = UIColor.white
20   -
21   - let path:UIBezierPath = UIBezierPath.init(roundedRect: contentView.bounds, byRoundingCorners: [.bottomLeft, .bottomRight], cornerRadii: CGSize.init(width: 20, height: 20))
  22 + let contentView = UIView.init(frame: CGRect(x: 0, y: 0, width: self.width, height: self.height-KTabBarHeight))
  23 + contentView.backgroundColor = UIColor.clear
22 24  
23   - let maskLayer:CAShapeLayer = CAShapeLayer()
24   - maskLayer.frame = contentView.bounds
25   - maskLayer.path = path.cgPath
26   - contentView.layer.mask = maskLayer
  25 +// let path:UIBezierPath = UIBezierPath.init(roundedRect: contentView.bounds, byRoundingCorners: [.bottomLeft, .bottomRight], cornerRadii: CGSize.init(width: 20, height: 20))
  26 +//
  27 +// let maskLayer:CAShapeLayer = CAShapeLayer()
  28 +// maskLayer.frame = contentView.bounds
  29 +// maskLayer.path = path.cgPath
  30 +// contentView.layer.mask = maskLayer
27 31  
28   - let imageView = UIImageView(frame: CGRect(x: 10, y: 20, width: contentView.width - 20, height: contentView.height - 40))
29   - imageView.image = UIImage(named: "homePage_collectMoneyImage")
30   - contentView.addSubview(imageView)
  32 +// let imageView = UIImageView(frame: CGRect(x: 10, y: 20, width: contentView.width - 20, height: contentView.height - 40))
  33 +// imageView.image = UIImage(named: "homePage_collectMoneyImage")
  34 +// contentView.addSubview(imageView)
31 35  
32 36 return contentView
33 37 }()
... ... @@ -39,6 +43,34 @@ class CNCollectMoneyCodeView:UIView{
39 43 return tempTopView
40 44 }()
41 45  
  46 + lazy var bottomView:UIView = {
  47 +
  48 + let bottomView = UIView(frame: CGRect(x:0, y:self.height - KTabBarHeight, width: self.width, height: KTabBarHeight))
  49 + bottomView.backgroundColor = .white
  50 + bottomView.isHidden = true
  51 +
  52 + let path:UIBezierPath = UIBezierPath.init(roundedRect: bottomView.bounds, byRoundingCorners: [.topLeft, .topRight], cornerRadii: CGSize.init(width: 20, height: 20))
  53 +
  54 + let maskLayer:CAShapeLayer = CAShapeLayer()
  55 + maskLayer.frame = bottomView.bounds
  56 + maskLayer.path = path.cgPath
  57 + bottomView.layer.mask = maskLayer
  58 +
  59 + let backBtn: UIButton = UIButton(type: .custom)
  60 + backBtn.frame = CGRectMake(0, 0, 100, 30)
  61 + backBtn.centerX = bottomView.width/2
  62 + backBtn.centerY = bottomView.height/2
  63 + backBtn.setImage(UIImage(named: "homePage_backhome_icon"), for: .normal)
  64 + backBtn.setTitle("回到首页", for: .normal)
  65 + backBtn.setTitleColor(UIColor("#2076FF"), for: .normal)
  66 + backBtn.titleLabel?.font = UIFont.systemFont(ofSize: 18, weight: .medium)
  67 + backBtn.addTarget(self, action: #selector(backBtnAction), for: .touchUpInside)
  68 + backBtn.imageEdgeInsets = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 8)
  69 + bottomView.addSubview(backBtn)
  70 +
  71 + return bottomView
  72 + }()
  73 +
42 74 override init(frame: CGRect) {
43 75 super.init(frame: frame)
44 76 self.initUI()
... ... @@ -53,6 +85,11 @@ class CNCollectMoneyCodeView:UIView{
53 85 func initUI(){
54 86 self.addSubview(self.contentView)
55 87 self.addSubview(self.topView)
  88 + self.addSubview(self.bottomView)
  89 + }
  90 +
  91 + @objc func backBtnAction(){
  92 + self.backAction!()
56 93 }
57 94  
58 95 }
... ...
metaCode/Classes/Main/HomePage/View/CNCustomIndexView.swift
... ... @@ -10,9 +10,10 @@ import Foundation
10 10 typealias closeBlock = ()->Void;
11 11  
12 12 class CNCustomIndexTopView : UIView{
13   - //关闭按钮事件回调
  13 + ///关闭按钮事件回调
14 14 var closeAction: closeBlock?
15 15  
  16 +
16 17 //MARK: - 懒加载
17 18 ///标题
18 19 lazy var titleLabel: UILabel = {
... ... @@ -70,8 +71,10 @@ protocol CNCustomIndexViewDelegate:NSObjectProtocol{
70 71  
71 72 class CNCustomIndexView:PGIndexBannerSubiew, UIScrollViewDelegate, WJColorChangeDelegate{
72 73  
  74 + ///记录开始拖拽时偏移量
  75 + var beginDragOffset: CGFloat = 0.0
73 76  
74   -
  77 + ///颜色管理
75 78 var colorChange: WJColorChange!
76 79  
77 80 ///代理
... ... @@ -136,12 +139,15 @@ class CNCustomIndexView:PGIndexBannerSubiew, UIScrollViewDelegate, WJColorChange
136 139 ///收钱view
137 140 lazy var collectMoneyCodeView: CNCollectMoneyCodeView = {
138 141 let collectionView = CNCollectMoneyCodeView.init(frame: CGRectMake(-25, 0, self.frame.size.width + 50, self.frame.size.height))
  142 + collectionView.backAction = {[weak self] in
  143 + self?.baseScrollView.setContentOffset(CGPoint(x: 0, y: (self!.baseScrollView.height)), animated: true)
  144 + }
139 145 return collectionView
140 146 }()
141 147  
142 148 ///付钱view
143 149 lazy var payMoneyCodeView : CNPayMoneyCodeView = {
144   - let payMoneyCodeView = CNPayMoneyCodeView(frame: CGRectMake(-25, self.frame.size.height*2 + 150,self.frame.size.width+50, self.frame.size.height - 150))
  150 + let payMoneyCodeView = CNPayMoneyCodeView(frame: CGRectMake(-25, self.frame.size.height*2 + 120,self.frame.size.width+50, self.frame.size.height - 120))
145 151  
146 152 return payMoneyCodeView
147 153 }()
... ... @@ -149,23 +155,27 @@ class CNCustomIndexView:PGIndexBannerSubiew, UIScrollViewDelegate, WJColorChange
149 155 ///上滑付钱提醒view
150 156 lazy var bottomPayMoneyRemindView: CNBottomPayMoneyRemindView = {
151 157 let W: CGFloat = UIScreen.main.bounds.width-100
152   - let bottomView = CNBottomPayMoneyRemindView.init(frame: CGRectMake(25, self.baseScrollView.height*2, W,W/2))
  158 + let H: CGFloat = W/2
  159 + let bottomView = CNBottomPayMoneyRemindView.init(frame: CGRectMake(25, self.height, W,H))
153 160 bottomView.backgroundColor = UIColor.clear
154 161 return bottomView
155 162 }()
156 163 /// 下滑收钱提醒view
157 164 lazy var topCollectMoneyRemindView:CNTopCollectMoneyRemindView = {
158 165 let W: CGFloat = UIScreen.main.bounds.width-100
159   - let topView = CNTopCollectMoneyRemindView.init(frame: CGRectMake(25, self.baseScrollView.height-W/2, W,W/2))
160   - topView.backgroundColor = .clear
  166 + let H: CGFloat = W/2
  167 + let topView = CNTopCollectMoneyRemindView.init(frame: CGRectMake(25, -H - 50, W,H))
  168 + topView.backgroundColor = .clear
  169 +
161 170 return topView
162 171 }()
163 172  
164 173 /// 顶部自定义导航
165 174 lazy var topNavView: CNCustomIndexTopView = {
166 175 let topNavView = CNCustomIndexTopView.init(frame: CGRect(x: 0, y: 0, width: self.width, height: KNavigationHeight))
167   - topNavView.closeAction = {
168   - print("点击了关闭按钮")
  176 + topNavView.alpha = 0
  177 + topNavView.closeAction = { [weak self ] in
  178 + self!.baseScrollView.setContentOffset(CGPoint(x: 0, y: self!.baseScrollView.height), animated: true)
169 179 }
170 180 return topNavView
171 181 }()
... ... @@ -182,6 +192,9 @@ class CNCustomIndexView:PGIndexBannerSubiew, UIScrollViewDelegate, WJColorChange
182 192  
183 193 // MARK: - 添加UI
184 194 func initUI(){
  195 + self.addSubview(self.bottomPayMoneyRemindView)
  196 + self.addSubview(self.topCollectMoneyRemindView)
  197 +
185 198 self.addSubview(self.baseScrollView)
186 199 self.addSubview(self.topNavView)
187 200 self.topNavView.setTitleString(title: "志愿者")
... ... @@ -189,8 +202,6 @@ class CNCustomIndexView:PGIndexBannerSubiew, UIScrollViewDelegate, WJColorChange
189 202 self.baseScrollView.addSubview(self.collectMoneyCodeView)
190 203 self.baseScrollView.addSubview(self.mainView)
191 204 self.baseScrollView.addSubview(self.payMoneyCodeView)
192   - self.baseScrollView.addSubview(self.bottomPayMoneyRemindView)
193   - self.baseScrollView.addSubview(self.topCollectMoneyRemindView)
194 205  
195 206 //默认偏移到中间
196 207 self.baseScrollView.setContentOffset(CGPointMake(0, self.frame.size.height), animated: false)
... ... @@ -218,7 +229,15 @@ class CNCustomIndexView:PGIndexBannerSubiew, UIScrollViewDelegate, WJColorChange
218 229 // MARK: - WJColorChange代理
219 230 ///将要开始拖拽滚动
220 231 func wjColorScrollViewWillBeginDragging(_ scrollView: UIScrollView!) {
  232 +
  233 + self.beginDragOffset = scrollView.contentOffset.y
  234 +
221 235 self.delegate?.customIndexViewWillBeiginScroll(scrollView: scrollView)
  236 +
  237 + //开始滑动把 baseScrollView 放到导航的上层
  238 + self.bringSubviewToFront(self.baseScrollView)
  239 +
  240 +
222 241 }
223 242  
224 243 ///WJColorChange 代理方法 滚动时候回调 传出当前的滚动视图
... ... @@ -243,30 +262,34 @@ class CNCustomIndexView:PGIndexBannerSubiew, UIScrollViewDelegate, WJColorChange
243 262 rightView?.alpha = (70-fabsOffset)/70.00
244 263 }
245 264  
  265 + //当self.baseScrollView的偏移量大于 self.baseScrollView.height时,显示上滑提醒view
  266 + if(currentOffset > self.baseScrollView.height){
  267 + self.bottomPayMoneyRemindView.top = self.height - (currentOffset - self.baseScrollView.height)*1.5
  268 + }
246 269 //上滑滑动到临近值,让bottomPayMoneyRemindView位置一直停留在底部,并慢慢消失
247   - let bottomPayMoneyRemindViewMaxOffset: CGFloat = self.baseScrollView.height+self.bottomPayMoneyRemindView.height
248   - if (currentOffset > bottomPayMoneyRemindViewMaxOffset) {
  270 + if (self.bottomPayMoneyRemindView.top < self.height - self.bottomPayMoneyRemindView.height) {
249 271 /**让bottomPayMoneyRemindView位置一直停留在底部*/
250   - self.bottomPayMoneyRemindView.top = currentOffset+self.baseScrollView.height-self.bottomPayMoneyRemindView.height
  272 + self.bottomPayMoneyRemindView.top = self.height - self.bottomPayMoneyRemindView.height
251 273  
252   - /**渐渐隐藏bottomPayMoneyRemindView,缓冲距离为40*/
253   - self.bottomPayMoneyRemindView.alpha = (40-(currentOffset - bottomPayMoneyRemindViewMaxOffset))/40.00
  274 + /**渐渐隐藏bottomPayMoneyRemindView,缓冲距离为20*/
  275 + let bottomPayMoneyRemindViewMaxOffset: CGFloat = self.baseScrollView.height+self.bottomPayMoneyRemindView.height
  276 + self.bottomPayMoneyRemindView.alpha = (20-(currentOffset - bottomPayMoneyRemindViewMaxOffset))/20.00
254 277  
255   - //让系统及时更新bottomPayMoneyRemindView
256   -// self.bottomPayMoneyRemindView.setNeedsLayout()
257   -// self.bottomPayMoneyRemindView.layoutIfNeeded()
258 278 }
259 279  
260   - //下滑滑动到临近值,让topCollectMoneyRemindView位置一直停留在底部,并慢慢消失
261   - let topCollectMoneyRemindViewMinOffset: CGFloat = self.baseScrollView.height-self.topCollectMoneyRemindView.height
262   - if (currentOffset < topCollectMoneyRemindViewMinOffset) {
  280 + //当self.baseScrollView的偏移量小于 self.baseScrollView.height时,显示下滑提醒view
  281 + if(currentOffset < self.baseScrollView.height){
  282 + self.topCollectMoneyRemindView.bottom = (self.baseScrollView.height - currentOffset)*1.5
  283 + }
  284 + //下滑滑动到临近值,让topCollectMoneyRemindView位置一直停留在顶部,并慢慢消失
  285 + if (self.topCollectMoneyRemindView.bottom > self.topCollectMoneyRemindView.height) {
  286 +
263 287 /**让topCollectMoneyRemindView位置一直停留在底部*/
264   - self.topCollectMoneyRemindView.bottom = currentOffset+self.topCollectMoneyRemindView.height
  288 + self.topCollectMoneyRemindView.bottom = self.topCollectMoneyRemindView.height
265 289  
266   - /**渐渐隐藏topCollectMoneyRemindView,缓冲距离为40*/
267   - print("currentOffset =", topCollectMoneyRemindViewMinOffset - currentOffset)
268   -
269   - self.topCollectMoneyRemindView.alpha = (40-(topCollectMoneyRemindViewMinOffset - currentOffset))/40.00
  290 + /**渐渐隐藏topCollectMoneyRemindView,缓冲距离为20*/
  291 + let topCollectMoneyRemindViewMinOffset: CGFloat = self.baseScrollView.height-self.topCollectMoneyRemindView.height
  292 + self.topCollectMoneyRemindView.alpha = (20-(topCollectMoneyRemindViewMinOffset - currentOffset))/20.00
270 293  
271 294 //让系统及时更新topCollectMoneyRemindView
272 295 // self.topCollectMoneyRemindView.setNeedsLayout()
... ... @@ -292,14 +315,19 @@ class CNCustomIndexView:PGIndexBannerSubiew, UIScrollViewDelegate, WJColorChange
292 315 // }
293 316  
294 317 /**隐藏顶部导航**/
295   - let topNavViewAlpha: CGFloat = 1.0 - (self.baseScrollView.height * 2 - currentOffset)/self.baseScrollView.height
  318 + let topNavViewAlpha: CGFloat = 1.0 - (self.baseScrollView.height * 2 - currentOffset)/(self.baseScrollView.height*0.5)
296 319 if(topNavViewAlpha > 0){
297   - self.topNavView.alpha = topNavViewAlpha/2
  320 + self.topNavView.alpha = topNavViewAlpha
298 321 }
299 322 else{
300 323 self.topNavView.alpha = 0
301 324 }
302   -
  325 +
  326 + //隐藏collectMoneyCodeView的bottomView
  327 + if scrollView.contentOffset.y > 10{
  328 + self.collectMoneyCodeView.bottomView.isHidden = true
  329 + self.collectMoneyCodeView.contentView.backgroundColor = .clear
  330 + }
303 331  
304 332 delegate?.customIndexViewDidScroll(scrollView: self.baseScrollView)
305 333  
... ... @@ -321,8 +349,24 @@ class CNCustomIndexView:PGIndexBannerSubiew, UIScrollViewDelegate, WJColorChange
321 349 else{
322 350 self.superScrollView?.isScrollEnabled = false
323 351 }
324   -
  352 +
  353 +
  354 + if scrollView.contentOffset.y == 0{
  355 + //滚动到第一页,显示collectMoneyCodeView的底部view
  356 + self.collectMoneyCodeView.bottomView.isHidden = false
  357 + self.collectMoneyCodeView.contentView.backgroundColor = KVCBackgroupColor
  358 + }
  359 +
  360 + //外部代理
325 361 self.delegate?.customIndexViewDidEndScroll(scrollView: scrollView)
  362 +
  363 +
  364 +
  365 + //滑动结束 把topNavView 放到scrollView的上层
  366 + self.bringSubviewToFront(self.topNavView)
  367 +
  368 + //下滑提醒View回到初始位置
  369 + self.topCollectMoneyRemindView.top = -(self.topCollectMoneyRemindView.height + 50)
326 370 }
327 371  
328 372 }
... ...
metaCode/Classes/Main/HomePage/View/CNHomePageBackgroupView.swift 0 → 100644
  1 +//
  2 +// CNHomePageBackgroupView.swift
  3 +// metaCode
  4 +//
  5 +// Created by daojian on 2023/6/6.
  6 +//
  7 +
  8 +import Foundation
  9 +import UIKit
  10 +class CNHomePageBackgroupSubView : UIView
  11 +{
  12 +
  13 + lazy var imageView: UIImageView = {
  14 + let imageView: UIImageView = UIImageView(image: UIImage(named: "homePage_backgroup_blue"))
  15 + imageView.frame = self.bounds
  16 + return imageView
  17 + }()
  18 +
  19 + lazy var titleLabel: UILabel = {
  20 + let titleLabel = UILabel.init(frame: CGRectMake(25, KNavigationHeight - 20, KSreenWidth - 100, 35))
  21 + titleLabel.textColor = .white
  22 + titleLabel.font = UIFont.systemFont(ofSize: 24, weight: .semibold)
  23 + return titleLabel
  24 + }()
  25 +
  26 +
  27 + override init(frame: CGRect) {
  28 + super.init(frame: frame)
  29 + self.initUI()
  30 + }
  31 +
  32 + required init?(coder: NSCoder) {
  33 + fatalError("init(coder:) has not been implemented")
  34 + }
  35 +
  36 + func initUI(){
  37 + self.addSubview(self.imageView)
  38 + self.addSubview(self.titleLabel)
  39 + }
  40 + ///设置title
  41 + func setTitle(title:String)->Void{
  42 + self.titleLabel.text = title
  43 + }
  44 + ///设置图片
  45 + func setImage(image:UIImage)->Void{
  46 + self.imageView.image = image
  47 + }
  48 +}
  49 +
  50 +class CNHomePageBackgroupView: UIView{
  51 +
  52 + // MARK: - 初始化
  53 + override init(frame: CGRect) {
  54 + super.init(frame: frame)
  55 + self.initUI()
  56 + }
  57 +
  58 + required init?(coder: NSCoder) {
  59 + fatalError("init(coder:) has not been implemented")
  60 + }
  61 +
  62 + //创建UI
  63 + func initUI(){
  64 + let subView: CNHomePageBackgroupSubView = CNHomePageBackgroupSubView.init(frame: self.bounds)
  65 + subView.frame = self.bounds
  66 + subView.setTitle(title: "志愿者")
  67 +
  68 + self.addSubview(subView)
  69 + }
  70 +
  71 +}
... ...
metaCode/Classes/Main/HomePage/View/CNMainView.swift
... ... @@ -47,7 +47,7 @@ class CNFrontMainView : UIView{
47 47 lazy var contentView : UIView = {
48 48  
49 49 let contentView = UIView.init(frame: CGRect(x: 0, y: 0, width: self.width, height: self.height ))
50   - contentView.backgroundColor = UIColor.red
  50 + contentView.backgroundColor = UIColor.white
51 51 contentView.clipsToBounds = true
52 52 contentView.layer.cornerRadius = 20
53 53  
... ...
metaCode/Classes/Main/HomePage/View/CNPayMoneyCodeView.swift
... ... @@ -26,10 +26,10 @@ class CNPayMoneyCodeView:UIView{
26 26 self.clipsToBounds = true;
27 27 self.layer.cornerRadius = 20;
28 28  
29   - let imageview : UIImageView = UIImageView.init(frame: CGRect(x: 20, y: 10, width: self.width - 40, height: self.height - 20))
30   - imageview.image = UIImage(named: "homePage_payMoneyImage")
31   -
32   - self.addSubview(imageview)
  29 +// let imageview : UIImageView = UIImageView.init(frame: CGRect(x: 20, y: 10, width: self.width - 40, height: self.height - 20))
  30 +// imageview.image = UIImage(named: "homePage_payMoneyImage")
  31 +//
  32 +// self.addSubview(imageview)
33 33  
34 34 }
35 35  
... ...
metaCode/Classes/Main/HomePage/View/CNTopCollectMoneyRemindView.swift
... ... @@ -40,17 +40,20 @@ class CNTopCollectMoneyRemindView : UIView{
40 40  
41 41 let bottomShapeLayer = CAShapeLayer()
42 42 bottomShapeLayer.path = bottomCircle.cgPath
43   - bottomShapeLayer.fillColor = UIColor("#FCE0E0")?.cgColor
  43 + bottomShapeLayer.fillColor = UIColor("#F0F5FD")?.cgColor
44 44 self.layer.addSublayer(bottomShapeLayer)
45 45  
46 46 let btn = UIButton(type: .custom)
47   - btn.frame = CGRect(x: (self.width - 50)/2, y: self.height-70, width: 50, height: 50)
48   - btn.setTitle("收钱", for: .normal)
49   - btn.setTitleColor(UIColor.red, for: .normal)
  47 + btn.frame = CGRect(x: (self.width - 50)/2, y: self.height-70, width: 50, height: 25)
  48 + btn.setTitle("下滑", for: .normal)
  49 + btn.setTitleColor(UIColor("#004FE0"), for: .normal)
50 50 btn.titleLabel?.font = UIFont(name: "KohinoorTelugu-Regular", size: 17)
51 51 btn.isUserInteractionEnabled = false
52   -
53 52 self.addSubview(btn)
  53 +
  54 + let imageView:UIImageView = UIImageView.init(image: UIImage(named: "homePage_down_icon"))
  55 + imageView.frame = CGRect(x: (self.width - 15)/2, y: btn.bottom, width: 15, height: 15)
  56 + self.addSubview(imageView)
54 57 }
55 58 }
56 59  
... ...
metaCode/Classes/Other/AppDelegate.swift
... ... @@ -19,7 +19,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
19 19 // Override point for customization after application launch.
20 20 window = UIWindow.init(frame: UIScreen.main.bounds)
21 21 window?.backgroundColor = KVCBackgroupColor
22   - window?.rootViewController = CNLiveLoginViewController.init()
  22 + window?.rootViewController = CNLiveBaseTabBarViewController.init()
23 23 window?.makeKeyAndVisible()
24 24  
25 25  
... ...
metaCode/Supporting Files/Assets.xcassets/Home/homePage_backgroup_blue.imageset/Contents.json 0 → 100644
  1 +{
  2 + "images" : [
  3 + {
  4 + "idiom" : "universal",
  5 + "scale" : "1x"
  6 + },
  7 + {
  8 + "filename" : "背景-蓝@2x.png",
  9 + "idiom" : "universal",
  10 + "scale" : "2x"
  11 + },
  12 + {
  13 + "filename" : "背景-蓝@3x.png",
  14 + "idiom" : "universal",
  15 + "scale" : "3x"
  16 + }
  17 + ],
  18 + "info" : {
  19 + "author" : "xcode",
  20 + "version" : 1
  21 + }
  22 +}
... ...
metaCode/Supporting Files/Assets.xcassets/Home/homePage_backgroup_blue.imageset/背景-蓝@2x.png 0 → 100644

60.9 KB

metaCode/Supporting Files/Assets.xcassets/Home/homePage_backgroup_blue.imageset/背景-蓝@3x.png 0 → 100644

155 KB

metaCode/Supporting Files/Assets.xcassets/Home/homePage_backgroup_red.imageset/Contents.json 0 → 100644
  1 +{
  2 + "images" : [
  3 + {
  4 + "idiom" : "universal",
  5 + "scale" : "1x"
  6 + },
  7 + {
  8 + "filename" : "背景-红@2x.png",
  9 + "idiom" : "universal",
  10 + "scale" : "2x"
  11 + },
  12 + {
  13 + "filename" : "背景-红@3x.png",
  14 + "idiom" : "universal",
  15 + "scale" : "3x"
  16 + }
  17 + ],
  18 + "info" : {
  19 + "author" : "xcode",
  20 + "version" : 1
  21 + }
  22 +}
... ...
metaCode/Supporting Files/Assets.xcassets/Home/homePage_backgroup_red.imageset/背景-红@2x.png 0 → 100644

58.6 KB

metaCode/Supporting Files/Assets.xcassets/Home/homePage_backgroup_red.imageset/背景-红@3x.png 0 → 100644

148 KB

metaCode/Supporting Files/Assets.xcassets/Home/homePage_backhome_icon.imageset/Contents.json 0 → 100644
  1 +{
  2 + "images" : [
  3 + {
  4 + "idiom" : "universal",
  5 + "scale" : "1x"
  6 + },
  7 + {
  8 + "filename" : "返回@2x.png",
  9 + "idiom" : "universal",
  10 + "scale" : "2x"
  11 + },
  12 + {
  13 + "filename" : "返回@3x.png",
  14 + "idiom" : "universal",
  15 + "scale" : "3x"
  16 + }
  17 + ],
  18 + "info" : {
  19 + "author" : "xcode",
  20 + "version" : 1
  21 + }
  22 +}
... ...
metaCode/Supporting Files/Assets.xcassets/Home/homePage_backhome_icon.imageset/返回@2x.png 0 → 100644

1.08 KB

metaCode/Supporting Files/Assets.xcassets/Home/homePage_backhome_icon.imageset/返回@3x.png 0 → 100644

2.01 KB

metaCode/Supporting Files/Assets.xcassets/Home/homePage_down_icon.imageset/Contents.json 0 → 100644
  1 +{
  2 + "images" : [
  3 + {
  4 + "idiom" : "universal",
  5 + "scale" : "1x"
  6 + },
  7 + {
  8 + "filename" : "下滑@2x.png",
  9 + "idiom" : "universal",
  10 + "scale" : "2x"
  11 + },
  12 + {
  13 + "filename" : "下滑@3x.png",
  14 + "idiom" : "universal",
  15 + "scale" : "3x"
  16 + }
  17 + ],
  18 + "info" : {
  19 + "author" : "xcode",
  20 + "version" : 1
  21 + }
  22 +}
... ...
metaCode/Supporting Files/Assets.xcassets/Home/homePage_down_icon.imageset/下滑@2x.png 0 → 100644

621 Bytes

metaCode/Supporting Files/Assets.xcassets/Home/homePage_down_icon.imageset/下滑@3x.png 0 → 100644

1.3 KB

metaCode/Supporting Files/Assets.xcassets/Home/homePage_up_icon.imageset/Contents.json 0 → 100644
  1 +{
  2 + "images" : [
  3 + {
  4 + "idiom" : "universal",
  5 + "scale" : "1x"
  6 + },
  7 + {
  8 + "filename" : "上滑@2x.png",
  9 + "idiom" : "universal",
  10 + "scale" : "2x"
  11 + },
  12 + {
  13 + "filename" : "上滑@3x.png",
  14 + "idiom" : "universal",
  15 + "scale" : "3x"
  16 + }
  17 + ],
  18 + "info" : {
  19 + "author" : "xcode",
  20 + "version" : 1
  21 + }
  22 +}
... ...
metaCode/Supporting Files/Assets.xcassets/Home/homePage_up_icon.imageset/上滑@2x.png 0 → 100644

638 Bytes

metaCode/Supporting Files/Assets.xcassets/Home/homePage_up_icon.imageset/上滑@3x.png 0 → 100644

1.27 KB