Commit 32f6fdde72b87d2edc6fdffe8a8bf985675c0158
Merge branch 'master' of http://bj.gitlab.cnlive.com/ios-team/CNLiveMateCode
# Conflicts: # metaCode/Classes/Other/AppDelegate.swift
Showing
32 changed files
with
731 additions
and
287 deletions
metaCode.xcodeproj/project.pbxproj
| @@ -37,6 +37,7 @@ | @@ -37,6 +37,7 @@ | ||
| 37 | 79A68C4C2A26EA6000DC3B43 /* (null) in Sources */ = {isa = PBXBuildFile; }; | 37 | 79A68C4C2A26EA6000DC3B43 /* (null) in Sources */ = {isa = PBXBuildFile; }; |
| 38 | 7C4931292A2D8BA8000E44B4 /* CNLiveBaseTabBarViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7C4931282A2D8BA8000E44B4 /* CNLiveBaseTabBarViewController.swift */; }; | 38 | 7C4931292A2D8BA8000E44B4 /* CNLiveBaseTabBarViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7C4931282A2D8BA8000E44B4 /* CNLiveBaseTabBarViewController.swift */; }; |
| 39 | 7C49312D2A2DB9FA000E44B4 /* UITabBar+CNBadge.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7C49312C2A2DB9FA000E44B4 /* UITabBar+CNBadge.swift */; }; | 39 | 7C49312D2A2DB9FA000E44B4 /* UITabBar+CNBadge.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7C49312C2A2DB9FA000E44B4 /* UITabBar+CNBadge.swift */; }; |
| 40 | + 7C4931312A2F142F000E44B4 /* CNHomePageBackgroupView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7C4931302A2F142F000E44B4 /* CNHomePageBackgroupView.swift */; }; | ||
| 40 | 7CD675292A270F6A008354C1 /* WJColorChange.m in Sources */ = {isa = PBXBuildFile; fileRef = 7CD675282A270F6A008354C1 /* WJColorChange.m */; }; | 41 | 7CD675292A270F6A008354C1 /* WJColorChange.m in Sources */ = {isa = PBXBuildFile; fileRef = 7CD675282A270F6A008354C1 /* WJColorChange.m */; }; |
| 41 | 7CD6753C2A2740B0008354C1 /* CNBottomPayMoneyRemindView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7CD675372A2740B0008354C1 /* CNBottomPayMoneyRemindView.swift */; }; | 42 | 7CD6753C2A2740B0008354C1 /* CNBottomPayMoneyRemindView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7CD675372A2740B0008354C1 /* CNBottomPayMoneyRemindView.swift */; }; |
| 42 | 7CD6753D2A2740B0008354C1 /* CNMainView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7CD675382A2740B0008354C1 /* CNMainView.swift */; }; | 43 | 7CD6753D2A2740B0008354C1 /* CNMainView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7CD675382A2740B0008354C1 /* CNMainView.swift */; }; |
| @@ -108,6 +109,7 @@ | @@ -108,6 +109,7 @@ | ||
| 108 | 79A68C512A26F59C00DC3B43 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = metaCode/Info.plist; sourceTree = "<group>"; }; | 109 | 79A68C512A26F59C00DC3B43 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = metaCode/Info.plist; sourceTree = "<group>"; }; |
| 109 | 7C4931282A2D8BA8000E44B4 /* CNLiveBaseTabBarViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNLiveBaseTabBarViewController.swift; sourceTree = "<group>"; }; | 110 | 7C4931282A2D8BA8000E44B4 /* CNLiveBaseTabBarViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNLiveBaseTabBarViewController.swift; sourceTree = "<group>"; }; |
| 110 | 7C49312C2A2DB9FA000E44B4 /* UITabBar+CNBadge.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UITabBar+CNBadge.swift"; sourceTree = "<group>"; }; | 111 | 7C49312C2A2DB9FA000E44B4 /* UITabBar+CNBadge.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UITabBar+CNBadge.swift"; sourceTree = "<group>"; }; |
| 112 | + 7C4931302A2F142F000E44B4 /* CNHomePageBackgroupView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNHomePageBackgroupView.swift; sourceTree = "<group>"; }; | ||
| 111 | 7CD675262A270F69008354C1 /* metaCode-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "metaCode-Bridging-Header.h"; sourceTree = "<group>"; }; | 113 | 7CD675262A270F69008354C1 /* metaCode-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "metaCode-Bridging-Header.h"; sourceTree = "<group>"; }; |
| 112 | 7CD675272A270F6A008354C1 /* WJColorChange.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WJColorChange.h; sourceTree = "<group>"; }; | 114 | 7CD675272A270F6A008354C1 /* WJColorChange.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WJColorChange.h; sourceTree = "<group>"; }; |
| 113 | 7CD675282A270F6A008354C1 /* WJColorChange.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WJColorChange.m; sourceTree = "<group>"; }; | 115 | 7CD675282A270F6A008354C1 /* WJColorChange.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WJColorChange.m; sourceTree = "<group>"; }; |
| @@ -383,6 +385,7 @@ | @@ -383,6 +385,7 @@ | ||
| 383 | 7CD675392A2740B0008354C1 /* CNPayMoneyCodeView.swift */, | 385 | 7CD675392A2740B0008354C1 /* CNPayMoneyCodeView.swift */, |
| 384 | 7CD6753A2A2740B0008354C1 /* CNTopCollectMoneyRemindView.swift */, | 386 | 7CD6753A2A2740B0008354C1 /* CNTopCollectMoneyRemindView.swift */, |
| 385 | 7CD675412A2740F8008354C1 /* CNCustomIndexView.swift */, | 387 | 7CD675412A2740F8008354C1 /* CNCustomIndexView.swift */, |
| 388 | + 7C4931302A2F142F000E44B4 /* CNHomePageBackgroupView.swift */, | ||
| 386 | ); | 389 | ); |
| 387 | name = View; | 390 | name = View; |
| 388 | path = HomePage/View; | 391 | path = HomePage/View; |
| @@ -729,6 +732,7 @@ | @@ -729,6 +732,7 @@ | ||
| 729 | 79A68C4A2A26E6CE00DC3B43 /* (null) in Sources */, | 732 | 79A68C4A2A26E6CE00DC3B43 /* (null) in Sources */, |
| 730 | 79282A3E2A2EFDA000B5F8CF /* CNLiveLoginModel.swift in Sources */, | 733 | 79282A3E2A2EFDA000B5F8CF /* CNLiveLoginModel.swift in Sources */, |
| 731 | 790D01852A2D89E100C5978D /* UIColor+CNHexColor.swift in Sources */, | 734 | 790D01852A2D89E100C5978D /* UIColor+CNHexColor.swift in Sources */, |
| 735 | + 7C4931312A2F142F000E44B4 /* CNHomePageBackgroupView.swift in Sources */, | ||
| 732 | 790D018B2A2D8B3300C5978D /* CNLiveLoginViewController.swift in Sources */, | 736 | 790D018B2A2D8B3300C5978D /* CNLiveLoginViewController.swift in Sources */, |
| 733 | 798A44EC2A302DBE00815935 /* CNLiveMineAddInfoViewController.swift in Sources */, | 737 | 798A44EC2A302DBE00815935 /* CNLiveMineAddInfoViewController.swift in Sources */, |
| 734 | 7CD675422A2740F8008354C1 /* CNCustomIndexView.swift in Sources */, | 738 | 7CD675422A2740F8008354C1 /* CNCustomIndexView.swift in Sources */, |
metaCode/Classes/Common/Base/CNLiveBaseTabBarViewController.swift
| @@ -8,17 +8,38 @@ | @@ -8,17 +8,38 @@ | ||
| 8 | import Foundation | 8 | import Foundation |
| 9 | import UIKit | 9 | import UIKit |
| 10 | 10 | ||
| 11 | -class CNLiveBaseTabBarViewController:UITabBarController | 11 | +class CNTabBar:UITabBar{ |
| 12 | + | ||
| 13 | + override var frame: CGRect { | ||
| 14 | + | ||
| 15 | + willSet | ||
| 16 | + { | ||
| 17 | + | ||
| 18 | + } | ||
| 19 | + //我们需要在age属性发生变化后,更新一下nickName这个属性 | ||
| 20 | + didSet | ||
| 21 | + { | ||
| 22 | + print("frame = ", frame) | ||
| 23 | + print("完成") | ||
| 24 | + } | ||
| 25 | + } | ||
| 26 | +} | ||
| 27 | + | ||
| 28 | +class CNLiveBaseTabBarViewController: UITabBarController | ||
| 12 | { | 29 | { |
| 13 | 30 | ||
| 14 | override func viewDidLoad() { | 31 | override func viewDidLoad() { |
| 15 | super.viewDidLoad() | 32 | super.viewDidLoad() |
| 33 | + self.setValue(CNTabBar.init(), forKey: "tabBar") | ||
| 34 | + | ||
| 35 | + self.setUpTabBar() | ||
| 36 | + self.setupBackgroup() | ||
| 37 | + | ||
| 16 | } | 38 | } |
| 17 | 39 | ||
| 18 | override func viewWillAppear(_ animated: Bool) { | 40 | override func viewWillAppear(_ animated: Bool) { |
| 19 | super.viewWillAppear(animated) | 41 | super.viewWillAppear(animated) |
| 20 | - self.setUpTabBar() | ||
| 21 | - self.setupBackgroup() | 42 | + |
| 22 | 43 | ||
| 23 | self.selectedIndex = 1 | 44 | self.selectedIndex = 1 |
| 24 | 45 | ||
| @@ -26,6 +47,7 @@ class CNLiveBaseTabBarViewController:UITabBarController | @@ -26,6 +47,7 @@ class CNLiveBaseTabBarViewController:UITabBarController | ||
| 26 | override func viewDidAppear(_ animated: Bool) { | 47 | override func viewDidAppear(_ animated: Bool) { |
| 27 | super.viewDidAppear(animated) | 48 | super.viewDidAppear(animated) |
| 28 | 49 | ||
| 50 | + | ||
| 29 | } | 51 | } |
| 30 | // MARK: - 控制器的信息 | 52 | // MARK: - 控制器的信息 |
| 31 | func setUpTabBar() { | 53 | func setUpTabBar() { |
metaCode/Classes/Constant/CNLiveConstant.swift
| @@ -13,11 +13,11 @@ let KSreenWidth = UIScreen.main.bounds.width | @@ -13,11 +13,11 @@ let KSreenWidth = UIScreen.main.bounds.width | ||
| 13 | let KSreenHeight = UIScreen.main.bounds.height | 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 | ///tabbar高度 | 19 | ///tabbar高度 |
| 20 | -let KTabBarHeight = (KStatusBarHeight == 44 ? 83 : 49) | 20 | +let KTabBarHeight:CGFloat = (KStatusBarHeight == 44 ? 83 : 49) |
| 21 | 21 | ||
| 22 | //MARK: - 常用背景色 | 22 | //MARK: - 常用背景色 |
| 23 | ///控制器背景色 | 23 | ///控制器背景色 |
metaCode/Classes/Extensions/UITabBar+CNBadge.swift
| @@ -8,208 +8,208 @@ | @@ -8,208 +8,208 @@ | ||
| 8 | import Foundation | 8 | import Foundation |
| 9 | import UIKit | 9 | import UIKit |
| 10 | 10 | ||
| 11 | -extension UITabBar { | ||
| 12 | - /** | ||
| 13 | - tabbar tag | ||
| 14 | - */ | ||
| 15 | - private var badgeTag:Int! { | ||
| 16 | - get{ | ||
| 17 | - return 1000 | ||
| 18 | - } | ||
| 19 | - set{ | ||
| 20 | - | ||
| 21 | - } | ||
| 22 | - } | ||
| 23 | - | ||
| 24 | - /** | ||
| 25 | - 运行时对应的key值 | ||
| 26 | - */ | ||
| 27 | - private struct AssociatedKeys { | ||
| 28 | - static var kBadgeSize:String! = "kBadgeSize" | ||
| 29 | - static var kBadgeColor:String! = "kBadgeColor" | ||
| 30 | - static var kBadgeImage:String! = "kBadgeImage" | ||
| 31 | - static var kBadgePoint:String! = "kBadgePoint" | ||
| 32 | - static var kBadgeValue:String! = "kBadgeValue" | ||
| 33 | - } | ||
| 34 | - | ||
| 35 | - | ||
| 36 | - // 小红点size | ||
| 37 | - public var badgeSize:CGSize! { | ||
| 38 | - get{ | ||
| 39 | - return objc_getAssociatedObject(self, &AssociatedKeys.kBadgeSize) as? CGSize | ||
| 40 | - } | ||
| 41 | - set{ | ||
| 42 | - objc_setAssociatedObject(self, &AssociatedKeys.kBadgeSize, newValue, .OBJC_ASSOCIATION_RETAIN_NONATOMIC) | ||
| 43 | - } | ||
| 44 | - } | ||
| 45 | - | ||
| 46 | - // 小红点图片 | ||
| 47 | - public var badgeImage:UIImage! { | ||
| 48 | - get{ | ||
| 49 | - return objc_getAssociatedObject(self, &AssociatedKeys.kBadgeImage) as? UIImage | ||
| 50 | - } | ||
| 51 | - set{ | ||
| 52 | - objc_setAssociatedObject(self, &AssociatedKeys.kBadgeImage, newValue, .OBJC_ASSOCIATION_RETAIN_NONATOMIC) | ||
| 53 | - } | ||
| 54 | - } | ||
| 55 | - | ||
| 56 | - // 小红点颜色 | ||
| 57 | - public var badgeColor:UIColor! { | ||
| 58 | - get{ | ||
| 59 | - return objc_getAssociatedObject(self, &AssociatedKeys.kBadgeColor) as? UIColor | ||
| 60 | - } | ||
| 61 | - set{ | ||
| 62 | - objc_setAssociatedObject(self, &AssociatedKeys.kBadgeColor, newValue, .OBJC_ASSOCIATION_RETAIN_NONATOMIC) | ||
| 63 | - } | ||
| 64 | - } | ||
| 65 | - | ||
| 66 | - // 小红点的x、y值 | ||
| 67 | - public var badgePoint:CGPoint! { | ||
| 68 | - get{ | ||
| 69 | - return objc_getAssociatedObject(self, &AssociatedKeys.kBadgePoint) as? CGPoint | ||
| 70 | - } | ||
| 71 | - set{ | ||
| 72 | - objc_setAssociatedObject(self, &AssociatedKeys.kBadgePoint, newValue, .OBJC_ASSOCIATION_RETAIN_NONATOMIC) | ||
| 73 | - } | ||
| 74 | - } | ||
| 75 | - | ||
| 76 | - // 小红点的数字 | ||
| 77 | - public var badgeValue:String! { | ||
| 78 | - get{ | ||
| 79 | - return objc_getAssociatedObject(self, &AssociatedKeys.kBadgeValue) as? String | ||
| 80 | - } | ||
| 81 | - set{ | ||
| 82 | - objc_setAssociatedObject(self, &AssociatedKeys.kBadgeValue, newValue, .OBJC_ASSOCIATION_RETAIN_NONATOMIC) | ||
| 83 | - } | ||
| 84 | - } | ||
| 85 | - | ||
| 86 | - // MARK:-显示小红点 | ||
| 87 | - public func showBadgeOnItemIndex(index:Int){ | ||
| 88 | - // 移除 | ||
| 89 | - self.removeRedPointOnIndex(index: index, animation: false) | ||
| 90 | - | ||
| 91 | - // 防止是空的 | ||
| 92 | - if self.badgeColor == nil { | ||
| 93 | - self.badgeColor = UIColor() | ||
| 94 | - self.badgeColor = UIColor.red | ||
| 95 | - } | ||
| 96 | - | ||
| 97 | - if self.badgePoint == nil { | ||
| 98 | - self.badgePoint = CGPoint() | ||
| 99 | - self.badgePoint = CGPoint.zero | ||
| 100 | - } | ||
| 101 | - | ||
| 102 | - if self.badgeSize == nil { | ||
| 103 | - self.badgeSize = CGSize.zero | ||
| 104 | - } | ||
| 105 | - | ||
| 106 | - if self.badgeImage == nil { | ||
| 107 | - self.badgeImage = UIImage() | ||
| 108 | - } | ||
| 109 | - | ||
| 110 | - if self.badgeValue == nil { | ||
| 111 | - self.badgeValue = String() | ||
| 112 | - } | ||
| 113 | - | ||
| 114 | - // 小红点背景默认值大小设置 | ||
| 115 | - if __CGSizeEqualToSize(self.badgeSize, CGSize.zero) { | ||
| 116 | - self.badgeSize = CGSize(width: 12, height: 12) | ||
| 117 | - } | ||
| 118 | - | ||
| 119 | - | ||
| 120 | - let badgeView = UIView() | ||
| 121 | - badgeView.backgroundColor = self.badgeColor | ||
| 122 | - badgeView.layer.cornerRadius = self.badgeSize.width / 2 | ||
| 123 | - badgeView.tag = badgeTag + 1 | ||
| 124 | - | ||
| 125 | - let barButtonView = self.getBarButttonViewWithIndex(index: index) | ||
| 126 | - //(图片的imageView) | ||
| 127 | - var iconView = UIView() | ||
| 128 | - for swappableImageView in barButtonView.subviews { | ||
| 129 | - | ||
| 130 | - if swappableImageView.isKind(of: UIImageView.self) { | ||
| 131 | - iconView = swappableImageView | ||
| 132 | - break | ||
| 133 | - } | ||
| 134 | - | ||
| 135 | - } | ||
| 136 | - | ||
| 137 | - // 小红点背景默认值Point设置 | ||
| 138 | - if __CGPointEqualToPoint(self.badgePoint, CGPoint.zero) { | ||
| 139 | - let iconViewSize = iconView.frame.size | ||
| 140 | - badgeView.frame = CGRect(x: iconViewSize.width - self.badgeSize.width / 2, y: -self.badgeSize.width / 2, width: self.badgeSize.width, height: self.badgeSize.height) | ||
| 141 | - }else{ | ||
| 142 | - badgeView.frame = CGRect(x: self.badgePoint.x, y: self.badgePoint.y, width: self.badgeSize.width, height: self.badgeSize.height) | ||
| 143 | - } | ||
| 144 | - | ||
| 145 | - // 添加图片到小红点上 | ||
| 146 | - let imageview = UIImageView(frame: badgeView.bounds) | ||
| 147 | - imageview.image = self.badgeImage | ||
| 148 | - if self.badgeImage != nil { | ||
| 149 | - self.backgroundColor = UIColor.red | ||
| 150 | - } | ||
| 151 | - badgeView.addSubview(imageview) | ||
| 152 | - | ||
| 153 | - if self.badgeValue != nil { | ||
| 154 | - let badgeLabel = UILabel(frame: badgeView.bounds) | ||
| 155 | - badgeLabel.text = self.badgeValue | ||
| 156 | - badgeLabel.textAlignment = .center | ||
| 157 | - badgeLabel.font = UIFont.systemFont(ofSize: 13) | ||
| 158 | - badgeLabel.textColor = UIColor.white | ||
| 159 | - badgeView.addSubview(badgeLabel) | ||
| 160 | - } | ||
| 161 | - | ||
| 162 | - iconView.addSubview(badgeView) | ||
| 163 | - } | ||
| 164 | - | ||
| 165 | - // MARK:-隐藏小红点 | ||
| 166 | - public func hiddenRedPointOnIndex(index:Int, animation:Bool){ | ||
| 167 | - self.removeRedPointOnIndex(index: index, animation: animation) | ||
| 168 | - } | ||
| 169 | - | ||
| 170 | - private func removeRedPointOnIndex(index:Int, animation:Bool) { | ||
| 171 | - let barButtonView = self.getBarButttonViewWithIndex(index: index) | ||
| 172 | - | ||
| 173 | - for swapView in barButtonView.subviews { | ||
| 174 | - | ||
| 175 | - if swapView.isKind(of: UIImageView.self) { | ||
| 176 | - | ||
| 177 | - for view1 in swapView.subviews { | ||
| 178 | - | ||
| 179 | - if view1.tag == (badgeTag + 1) { | ||
| 180 | - | ||
| 181 | - if animation { | ||
| 182 | - UIView.animate(withDuration: 0.2, animations: { | ||
| 183 | - view1.transform = CGAffineTransform(translationX: 2, y: 2) | ||
| 184 | - view1.alpha = 0 | ||
| 185 | - }) { (finished) in | ||
| 186 | - view1.removeFromSuperview() | ||
| 187 | - } | ||
| 188 | - }else{ | ||
| 189 | - view1.removeFromSuperview() | ||
| 190 | - } | ||
| 191 | - | ||
| 192 | - } | ||
| 193 | - | ||
| 194 | - } | ||
| 195 | - | ||
| 196 | - } | ||
| 197 | - | ||
| 198 | - } | ||
| 199 | - | ||
| 200 | - } | ||
| 201 | - | ||
| 202 | - // 获取barButtonView | ||
| 203 | - private func getBarButttonViewWithIndex(index:Int) -> UIView { | ||
| 204 | - | ||
| 205 | - if let itemss = self.items { | ||
| 206 | - let item = itemss[index] | ||
| 207 | - let barButtonView = item.value(forKey: "view") | ||
| 208 | - return barButtonView as! UIView | ||
| 209 | - } | ||
| 210 | - | ||
| 211 | - let vw = UIView() | ||
| 212 | - return vw | ||
| 213 | - } | ||
| 214 | - | ||
| 215 | -} | 11 | +//extension UITabBar { |
| 12 | +// /** | ||
| 13 | +// tabbar tag | ||
| 14 | +// */ | ||
| 15 | +// private var badgeTag:Int! { | ||
| 16 | +// get{ | ||
| 17 | +// return 1000 | ||
| 18 | +// } | ||
| 19 | +// set{ | ||
| 20 | +// | ||
| 21 | +// } | ||
| 22 | +// } | ||
| 23 | +// | ||
| 24 | +// /** | ||
| 25 | +// 运行时对应的key值 | ||
| 26 | +// */ | ||
| 27 | +// private struct AssociatedKeys { | ||
| 28 | +// static var kBadgeSize:String! = "kBadgeSize" | ||
| 29 | +// static var kBadgeColor:String! = "kBadgeColor" | ||
| 30 | +// static var kBadgeImage:String! = "kBadgeImage" | ||
| 31 | +// static var kBadgePoint:String! = "kBadgePoint" | ||
| 32 | +// static var kBadgeValue:String! = "kBadgeValue" | ||
| 33 | +// } | ||
| 34 | +// | ||
| 35 | +// | ||
| 36 | +// // 小红点size | ||
| 37 | +// public var badgeSize:CGSize! { | ||
| 38 | +// get{ | ||
| 39 | +// return objc_getAssociatedObject(self, &AssociatedKeys.kBadgeSize) as? CGSize | ||
| 40 | +// } | ||
| 41 | +// set{ | ||
| 42 | +// objc_setAssociatedObject(self, &AssociatedKeys.kBadgeSize, newValue, .OBJC_ASSOCIATION_RETAIN_NONATOMIC) | ||
| 43 | +// } | ||
| 44 | +// } | ||
| 45 | +// | ||
| 46 | +// // 小红点图片 | ||
| 47 | +// public var badgeImage:UIImage! { | ||
| 48 | +// get{ | ||
| 49 | +// return objc_getAssociatedObject(self, &AssociatedKeys.kBadgeImage) as? UIImage | ||
| 50 | +// } | ||
| 51 | +// set{ | ||
| 52 | +// objc_setAssociatedObject(self, &AssociatedKeys.kBadgeImage, newValue, .OBJC_ASSOCIATION_RETAIN_NONATOMIC) | ||
| 53 | +// } | ||
| 54 | +// } | ||
| 55 | +// | ||
| 56 | +// // 小红点颜色 | ||
| 57 | +// public var badgeColor:UIColor! { | ||
| 58 | +// get{ | ||
| 59 | +// return objc_getAssociatedObject(self, &AssociatedKeys.kBadgeColor) as? UIColor | ||
| 60 | +// } | ||
| 61 | +// set{ | ||
| 62 | +// objc_setAssociatedObject(self, &AssociatedKeys.kBadgeColor, newValue, .OBJC_ASSOCIATION_RETAIN_NONATOMIC) | ||
| 63 | +// } | ||
| 64 | +// } | ||
| 65 | +// | ||
| 66 | +// // 小红点的x、y值 | ||
| 67 | +// public var badgePoint:CGPoint! { | ||
| 68 | +// get{ | ||
| 69 | +// return objc_getAssociatedObject(self, &AssociatedKeys.kBadgePoint) as? CGPoint | ||
| 70 | +// } | ||
| 71 | +// set{ | ||
| 72 | +// objc_setAssociatedObject(self, &AssociatedKeys.kBadgePoint, newValue, .OBJC_ASSOCIATION_RETAIN_NONATOMIC) | ||
| 73 | +// } | ||
| 74 | +// } | ||
| 75 | +// | ||
| 76 | +// // 小红点的数字 | ||
| 77 | +// public var badgeValue:String! { | ||
| 78 | +// get{ | ||
| 79 | +// return objc_getAssociatedObject(self, &AssociatedKeys.kBadgeValue) as? String | ||
| 80 | +// } | ||
| 81 | +// set{ | ||
| 82 | +// objc_setAssociatedObject(self, &AssociatedKeys.kBadgeValue, newValue, .OBJC_ASSOCIATION_RETAIN_NONATOMIC) | ||
| 83 | +// } | ||
| 84 | +// } | ||
| 85 | +// | ||
| 86 | +// // MARK:-显示小红点 | ||
| 87 | +// public func showBadgeOnItemIndex(index:Int){ | ||
| 88 | +// // 移除 | ||
| 89 | +// self.removeRedPointOnIndex(index: index, animation: false) | ||
| 90 | +// | ||
| 91 | +// // 防止是空的 | ||
| 92 | +// if self.badgeColor == nil { | ||
| 93 | +// self.badgeColor = UIColor() | ||
| 94 | +// self.badgeColor = UIColor.red | ||
| 95 | +// } | ||
| 96 | +// | ||
| 97 | +// if self.badgePoint == nil { | ||
| 98 | +// self.badgePoint = CGPoint() | ||
| 99 | +// self.badgePoint = CGPoint.zero | ||
| 100 | +// } | ||
| 101 | +// | ||
| 102 | +// if self.badgeSize == nil { | ||
| 103 | +// self.badgeSize = CGSize.zero | ||
| 104 | +// } | ||
| 105 | +// | ||
| 106 | +// if self.badgeImage == nil { | ||
| 107 | +// self.badgeImage = UIImage() | ||
| 108 | +// } | ||
| 109 | +// | ||
| 110 | +// if self.badgeValue == nil { | ||
| 111 | +// self.badgeValue = String() | ||
| 112 | +// } | ||
| 113 | +// | ||
| 114 | +// // 小红点背景默认值大小设置 | ||
| 115 | +// if __CGSizeEqualToSize(self.badgeSize, CGSize.zero) { | ||
| 116 | +// self.badgeSize = CGSize(width: 12, height: 12) | ||
| 117 | +// } | ||
| 118 | +// | ||
| 119 | +// | ||
| 120 | +// let badgeView = UIView() | ||
| 121 | +// badgeView.backgroundColor = self.badgeColor | ||
| 122 | +// badgeView.layer.cornerRadius = self.badgeSize.width / 2 | ||
| 123 | +// badgeView.tag = badgeTag + 1 | ||
| 124 | +// | ||
| 125 | +// let barButtonView = self.getBarButttonViewWithIndex(index: index) | ||
| 126 | +// //(图片的imageView) | ||
| 127 | +// var iconView = UIView() | ||
| 128 | +// for swappableImageView in barButtonView.subviews { | ||
| 129 | +// | ||
| 130 | +// if swappableImageView.isKind(of: UIImageView.self) { | ||
| 131 | +// iconView = swappableImageView | ||
| 132 | +// break | ||
| 133 | +// } | ||
| 134 | +// | ||
| 135 | +// } | ||
| 136 | +// | ||
| 137 | +// // 小红点背景默认值Point设置 | ||
| 138 | +// if __CGPointEqualToPoint(self.badgePoint, CGPoint.zero) { | ||
| 139 | +// let iconViewSize = iconView.frame.size | ||
| 140 | +// badgeView.frame = CGRect(x: iconViewSize.width - self.badgeSize.width / 2, y: -self.badgeSize.width / 2, width: self.badgeSize.width, height: self.badgeSize.height) | ||
| 141 | +// }else{ | ||
| 142 | +// badgeView.frame = CGRect(x: self.badgePoint.x, y: self.badgePoint.y, width: self.badgeSize.width, height: self.badgeSize.height) | ||
| 143 | +// } | ||
| 144 | +// | ||
| 145 | +// // 添加图片到小红点上 | ||
| 146 | +// let imageview = UIImageView(frame: badgeView.bounds) | ||
| 147 | +// imageview.image = self.badgeImage | ||
| 148 | +// if self.badgeImage != nil { | ||
| 149 | +// self.backgroundColor = UIColor.red | ||
| 150 | +// } | ||
| 151 | +// badgeView.addSubview(imageview) | ||
| 152 | +// | ||
| 153 | +// if self.badgeValue != nil { | ||
| 154 | +// let badgeLabel = UILabel(frame: badgeView.bounds) | ||
| 155 | +// badgeLabel.text = self.badgeValue | ||
| 156 | +// badgeLabel.textAlignment = .center | ||
| 157 | +// badgeLabel.font = UIFont.systemFont(ofSize: 13) | ||
| 158 | +// badgeLabel.textColor = UIColor.white | ||
| 159 | +// badgeView.addSubview(badgeLabel) | ||
| 160 | +// } | ||
| 161 | +// | ||
| 162 | +// iconView.addSubview(badgeView) | ||
| 163 | +// } | ||
| 164 | +// | ||
| 165 | +// // MARK:-隐藏小红点 | ||
| 166 | +// public func hiddenRedPointOnIndex(index:Int, animation:Bool){ | ||
| 167 | +// self.removeRedPointOnIndex(index: index, animation: animation) | ||
| 168 | +// } | ||
| 169 | +// | ||
| 170 | +// private func removeRedPointOnIndex(index:Int, animation:Bool) { | ||
| 171 | +// let barButtonView = self.getBarButttonViewWithIndex(index: index) | ||
| 172 | +// | ||
| 173 | +// for swapView in barButtonView.subviews { | ||
| 174 | +// | ||
| 175 | +// if swapView.isKind(of: UIImageView.self) { | ||
| 176 | +// | ||
| 177 | +// for view1 in swapView.subviews { | ||
| 178 | +// | ||
| 179 | +// if view1.tag == (badgeTag + 1) { | ||
| 180 | +// | ||
| 181 | +// if animation { | ||
| 182 | +// UIView.animate(withDuration: 0.2, animations: { | ||
| 183 | +// view1.transform = CGAffineTransform(translationX: 2, y: 2) | ||
| 184 | +// view1.alpha = 0 | ||
| 185 | +// }) { (finished) in | ||
| 186 | +// view1.removeFromSuperview() | ||
| 187 | +// } | ||
| 188 | +// }else{ | ||
| 189 | +// view1.removeFromSuperview() | ||
| 190 | +// } | ||
| 191 | +// | ||
| 192 | +// } | ||
| 193 | +// | ||
| 194 | +// } | ||
| 195 | +// | ||
| 196 | +// } | ||
| 197 | +// | ||
| 198 | +// } | ||
| 199 | +// | ||
| 200 | +// } | ||
| 201 | +// | ||
| 202 | +// // 获取barButtonView | ||
| 203 | +// private func getBarButttonViewWithIndex(index:Int) -> UIView { | ||
| 204 | +// | ||
| 205 | +// if let itemss = self.items { | ||
| 206 | +// let item = itemss[index] | ||
| 207 | +// let barButtonView = item.value(forKey: "view") | ||
| 208 | +// return barButtonView as! UIView | ||
| 209 | +// } | ||
| 210 | +// | ||
| 211 | +// let vw = UIView() | ||
| 212 | +// return vw | ||
| 213 | +// } | ||
| 214 | +// | ||
| 215 | +//} |
metaCode/Classes/Main/HomePage/Controller/CNMetaCodeHomePageController.swift
| @@ -14,6 +14,8 @@ let Height: CGFloat = UIScreen.main.bounds.size.height | @@ -14,6 +14,8 @@ let Height: CGFloat = UIScreen.main.bounds.size.height | ||
| 14 | 14 | ||
| 15 | class CNMetaCodeHomePageController:CNLiveBaseViewController, NewPagedFlowViewDelegate, NewPagedFlowViewDataSource, CNCustomIndexViewDelegate{ | 15 | class CNMetaCodeHomePageController:CNLiveBaseViewController, NewPagedFlowViewDelegate, NewPagedFlowViewDataSource, CNCustomIndexViewDelegate{ |
| 16 | 16 | ||
| 17 | + | ||
| 18 | + | ||
| 17 | private var tabBarY:CGFloat = 0.0 | 19 | private var tabBarY:CGFloat = 0.0 |
| 18 | 20 | ||
| 19 | // MARK: - 懒加载 | 21 | // MARK: - 懒加载 |
| @@ -25,42 +27,61 @@ class CNMetaCodeHomePageController:CNLiveBaseViewController, NewPagedFlowViewDel | @@ -25,42 +27,61 @@ class CNMetaCodeHomePageController:CNLiveBaseViewController, NewPagedFlowViewDel | ||
| 25 | 27 | ||
| 26 | ///左右滑动分页view | 28 | ///左右滑动分页view |
| 27 | lazy var pageFlowView: NewPagedFlowView = { | 29 | lazy var pageFlowView: NewPagedFlowView = { |
| 28 | - let pageFlowView = NewPagedFlowView.init(frame: CGRectMake(0, 0, Width, Height)); | 30 | + let pageFlowView = NewPagedFlowView.init(frame: CGRectMake(0, 0, Width, Height)) |
| 29 | 31 | ||
| 30 | - pageFlowView.delegate = self; | ||
| 31 | - pageFlowView.dataSource = self; | ||
| 32 | - pageFlowView.minimumPageAlpha = 0.1; | ||
| 33 | - pageFlowView.isCarousel = false; | ||
| 34 | - pageFlowView.orientation = .horizontal; | ||
| 35 | - pageFlowView.leftRightMargin = 20; | ||
| 36 | - 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 | ||
| 37 | 39 | ||
| 38 | //左右图片的距离顶部和底部的高度 | 40 | //左右图片的距离顶部和底部的高度 |
| 39 | - pageFlowView.topBottomMargin = 100; | 41 | + pageFlowView.topBottomMargin = 100 |
| 40 | 42 | ||
| 41 | return pageFlowView | 43 | return pageFlowView |
| 42 | 44 | ||
| 43 | }() | 45 | }() |
| 44 | 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 | + | ||
| 45 | //MARK: 生命周期方法 | 53 | //MARK: 生命周期方法 |
| 46 | override func viewDidLoad() { | 54 | override func viewDidLoad() { |
| 47 | super.viewDidLoad() | 55 | super.viewDidLoad() |
| 48 | 56 | ||
| 49 | self.tabBarY = (self.tabBarController?.tabBar.top)! | 57 | self.tabBarY = (self.tabBarController?.tabBar.top)! |
| 50 | 58 | ||
| 51 | - self.view.backgroundColor = KVCBackgroupColor | ||
| 52 | 59 | ||
| 53 | - for i in (0..<2) { | 60 | + for i in (0..<6) { |
| 54 | self.dataArray.add("122") | 61 | self.dataArray.add("122") |
| 55 | } | 62 | } |
| 56 | 63 | ||
| 57 | self.setupUI() | 64 | self.setupUI() |
| 65 | + | ||
| 66 | +// self.tabBarController?.tabBar.top = self.tabBarY + KSreenHeight | ||
| 67 | + | ||
| 68 | + } | ||
| 69 | + override func viewWillAppear(_ animated: Bool) { | ||
| 70 | + super.viewWillAppear(animated) | ||
| 71 | + } | ||
| 72 | + override func viewDidAppear(_ animated: Bool) { | ||
| 73 | + super.viewDidAppear(animated) | ||
| 74 | + self.view.height = KSreenHeight | ||
| 75 | + | ||
| 76 | + | ||
| 58 | } | 77 | } |
| 59 | - | ||
| 60 | // MARK: - 添加UI | 78 | // MARK: - 添加UI |
| 61 | func setupUI(){ | 79 | func setupUI(){ |
| 80 | + self.view.backgroundColor = KVCBackgroupColor | ||
| 81 | + self.view.addSubview(self.backgroupView) | ||
| 62 | self.view.addSubview(self.pageFlowView) | 82 | self.view.addSubview(self.pageFlowView) |
| 63 | self.pageFlowView.reloadData() | 83 | self.pageFlowView.reloadData() |
| 84 | + | ||
| 64 | } | 85 | } |
| 65 | 86 | ||
| 66 | // MARK: - NewPagedFlowView代理 | 87 | // MARK: - NewPagedFlowView代理 |
| @@ -70,18 +91,18 @@ class CNMetaCodeHomePageController:CNLiveBaseViewController, NewPagedFlowViewDel | @@ -70,18 +91,18 @@ class CNMetaCodeHomePageController:CNLiveBaseViewController, NewPagedFlowViewDel | ||
| 70 | } | 91 | } |
| 71 | 92 | ||
| 72 | func flowView(_ flowView: NewPagedFlowView!, cellForPageAt index: Int) -> PGIndexBannerSubiew! { | 93 | func flowView(_ flowView: NewPagedFlowView!, cellForPageAt index: Int) -> PGIndexBannerSubiew! { |
| 73 | - var bannerView:CNCustomIndexView? = flowView.dequeueReusableCell() as? CNCustomIndexView; | 94 | + var bannerView:CNCustomIndexView? = flowView.dequeueReusableCell() as? CNCustomIndexView |
| 74 | 95 | ||
| 75 | if (bannerView == nil) { | 96 | if (bannerView == nil) { |
| 76 | - bannerView = CNCustomIndexView.init(frame: CGRectMake(0, 0, Width-50, Height)); | ||
| 77 | - bannerView?.tag = index + 100; | ||
| 78 | - bannerView?.layer.cornerRadius = 4; | ||
| 79 | - 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 | ||
| 80 | } | 101 | } |
| 81 | - bannerView?.superScrollView = flowView.scrollView; | ||
| 82 | - bannerView?.associatedVCView = self.view; | 102 | + bannerView?.superScrollView = flowView.scrollView |
| 103 | + bannerView?.associatedVCView = self.view | ||
| 83 | bannerView?.delegate = self | 104 | bannerView?.delegate = self |
| 84 | - return bannerView; | 105 | + return bannerView |
| 85 | } | 106 | } |
| 86 | 107 | ||
| 87 | func sizeForPage(in flowView: NewPagedFlowView!) -> CGSize { | 108 | func sizeForPage(in flowView: NewPagedFlowView!) -> CGSize { |
| @@ -89,9 +110,23 @@ class CNMetaCodeHomePageController:CNLiveBaseViewController, NewPagedFlowViewDel | @@ -89,9 +110,23 @@ class CNMetaCodeHomePageController:CNLiveBaseViewController, NewPagedFlowViewDel | ||
| 89 | } | 110 | } |
| 90 | 111 | ||
| 91 | //MARK: - CNCustomIndexView 代理方法 | 112 | //MARK: - CNCustomIndexView 代理方法 |
| 113 | + func customIndexViewWillBeiginScroll(scrollView: UIScrollView) { | ||
| 114 | + self.view.height = KSreenHeight | ||
| 115 | + } | ||
| 92 | func customIndexViewDidScroll(scrollView: UIScrollView) { | 116 | func customIndexViewDidScroll(scrollView: UIScrollView) { |
| 117 | + //让tabbar跟随scrollView平移量进行移动 | ||
| 93 | let fabsOffset: CGFloat = abs(scrollView.contentOffset.y - KSreenHeight) | 118 | let fabsOffset: CGFloat = abs(scrollView.contentOffset.y - KSreenHeight) |
| 94 | self.tabBarController?.tabBar.top = self.tabBarY + fabsOffset | 119 | self.tabBarController?.tabBar.top = self.tabBarY + fabsOffset |
| 120 | + | ||
| 121 | + //让背景view也跟随scrollView平移量的3倍速进行移动 | ||
| 122 | + self.backgroupView.top = -fabsOffset*3 | ||
| 123 | + } | ||
| 124 | + | ||
| 125 | + | ||
| 126 | + func customIndexViewDidEndScroll(scrollView: UIScrollView) { | ||
| 127 | + if scrollView.contentOffset.y == KSreenHeight { | ||
| 128 | + self.view.height = self.tabBarY | ||
| 129 | + } | ||
| 95 | } | 130 | } |
| 96 | 131 | ||
| 97 | } | 132 | } |
metaCode/Classes/Main/HomePage/View/CNBottomPayMoneyRemindView.swift
| @@ -27,13 +27,17 @@ class CNBottomPayMoneyRemindView:UIView{ | @@ -27,13 +27,17 @@ class CNBottomPayMoneyRemindView:UIView{ | ||
| 27 | 27 | ||
| 28 | let bottomShapeLayer = CAShapeLayer() | 28 | let bottomShapeLayer = CAShapeLayer() |
| 29 | bottomShapeLayer.path = bottomCircle.cgPath | 29 | bottomShapeLayer.path = bottomCircle.cgPath |
| 30 | - bottomShapeLayer.fillColor = UIColor("#FCE0E0")?.cgColor | 30 | + bottomShapeLayer.fillColor = UIColor("#F0F5FD")?.cgColor |
| 31 | self.layer.addSublayer(bottomShapeLayer) | 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 | let btn = UIButton(type: .custom) | 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 | btn.titleLabel?.font = UIFont(name: "KohinoorTelugu-Regular", size: 17) | 41 | btn.titleLabel?.font = UIFont(name: "KohinoorTelugu-Regular", size: 17) |
| 38 | btn.isUserInteractionEnabled = false | 42 | btn.isUserInteractionEnabled = false |
| 39 | 43 |
metaCode/Classes/Main/HomePage/View/CNCollectMoneyCodeView.swift
| @@ -9,25 +9,29 @@ import Foundation | @@ -9,25 +9,29 @@ import Foundation | ||
| 9 | import UIKit | 9 | import UIKit |
| 10 | import YYCategories | 10 | import YYCategories |
| 11 | 11 | ||
| 12 | +typealias backBlock = ()->Void; | ||
| 13 | + | ||
| 12 | ///收钱码View | 14 | ///收钱码View |
| 13 | class CNCollectMoneyCodeView:UIView{ | 15 | class CNCollectMoneyCodeView:UIView{ |
| 16 | + //返回首页 | ||
| 17 | + var backAction:backBlock? | ||
| 14 | 18 | ||
| 15 | - ///懒加载 | 19 | + //MARK: - 懒加载 |
| 16 | lazy var contentView:UIView = { | 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 | return contentView | 36 | return contentView |
| 33 | }() | 37 | }() |
| @@ -39,6 +43,34 @@ class CNCollectMoneyCodeView:UIView{ | @@ -39,6 +43,34 @@ class CNCollectMoneyCodeView:UIView{ | ||
| 39 | return tempTopView | 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 | override init(frame: CGRect) { | 74 | override init(frame: CGRect) { |
| 43 | super.init(frame: frame) | 75 | super.init(frame: frame) |
| 44 | self.initUI() | 76 | self.initUI() |
| @@ -53,6 +85,11 @@ class CNCollectMoneyCodeView:UIView{ | @@ -53,6 +85,11 @@ class CNCollectMoneyCodeView:UIView{ | ||
| 53 | func initUI(){ | 85 | func initUI(){ |
| 54 | self.addSubview(self.contentView) | 86 | self.addSubview(self.contentView) |
| 55 | self.addSubview(self.topView) | 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
| @@ -7,14 +7,74 @@ | @@ -7,14 +7,74 @@ | ||
| 7 | 7 | ||
| 8 | import Foundation | 8 | import Foundation |
| 9 | 9 | ||
| 10 | +typealias closeBlock = ()->Void; | ||
| 11 | + | ||
| 12 | +class CNCustomIndexTopView : UIView{ | ||
| 13 | + ///关闭按钮事件回调 | ||
| 14 | + var closeAction: closeBlock? | ||
| 15 | + | ||
| 16 | + | ||
| 17 | + //MARK: - 懒加载 | ||
| 18 | + ///标题 | ||
| 19 | + lazy var titleLabel: UILabel = { | ||
| 20 | + let titleLabel = UILabel.init(frame: CGRectMake(10, 0, 75, 35)) | ||
| 21 | + titleLabel.bottom = self.bottom - 5 | ||
| 22 | + titleLabel.textColor = .white | ||
| 23 | + titleLabel.font = UIFont.systemFont(ofSize: 24, weight: .semibold) | ||
| 24 | + return titleLabel | ||
| 25 | + }() | ||
| 26 | + ///关闭按钮 | ||
| 27 | + lazy var closeBtn: UIButton = { | ||
| 28 | + let closeBtn = UIButton(type: .custom) | ||
| 29 | + closeBtn.frame = CGRect(x: self.width - 30, y: 0, width: 30, height: 30) | ||
| 30 | + closeBtn.centerY = self.titleLabel.centerY | ||
| 31 | + closeBtn.setImage(UIImage(named: "homePage_close_icon"), for: .normal) | ||
| 32 | + closeBtn.addTarget(self, action: #selector(closeBtnAction), for: .touchUpInside) | ||
| 33 | + return closeBtn | ||
| 34 | + }() | ||
| 35 | + //MARK: - 初始化 | ||
| 36 | + override init(frame: CGRect) { | ||
| 37 | + super.init(frame: frame) | ||
| 38 | + self.initUI() | ||
| 39 | + } | ||
| 40 | + | ||
| 41 | + required init?(coder: NSCoder) { | ||
| 42 | + fatalError("init(coder:) has not been implemented") | ||
| 43 | + } | ||
| 44 | + | ||
| 45 | + func initUI(){ | ||
| 46 | + self.addSubview(self.titleLabel) | ||
| 47 | + self.addSubview(self.closeBtn) | ||
| 48 | + } | ||
| 49 | + | ||
| 50 | + //MARK: - 公开方法 | ||
| 51 | + public func setTitleString(title:String)->Void{ | ||
| 52 | + self.titleLabel.text = title | ||
| 53 | + } | ||
| 54 | + | ||
| 55 | + //MARK: - 事件 | ||
| 56 | + @objc func closeBtnAction(){ | ||
| 57 | + closeAction?() | ||
| 58 | + } | ||
| 59 | +} | ||
| 60 | + | ||
| 10 | 61 | ||
| 11 | protocol CNCustomIndexViewDelegate:NSObjectProtocol{ | 62 | protocol CNCustomIndexViewDelegate:NSObjectProtocol{ |
| 12 | - ///当前scrollView 发送滚动 | 63 | + /// 当前scrollView 将要开始滚动 |
| 64 | + func customIndexViewWillBeiginScroll(scrollView :UIScrollView); | ||
| 65 | + ///当前scrollView 滚动中 | ||
| 13 | func customIndexViewDidScroll(scrollView :UIScrollView); | 66 | func customIndexViewDidScroll(scrollView :UIScrollView); |
| 67 | + ///当前scrollView 已经结束滚动 | ||
| 68 | + func customIndexViewDidEndScroll(scrollView :UIScrollView); | ||
| 69 | + | ||
| 14 | } | 70 | } |
| 15 | 71 | ||
| 16 | class CNCustomIndexView:PGIndexBannerSubiew, UIScrollViewDelegate, WJColorChangeDelegate{ | 72 | class CNCustomIndexView:PGIndexBannerSubiew, UIScrollViewDelegate, WJColorChangeDelegate{ |
| 73 | + | ||
| 74 | + ///记录开始拖拽时偏移量 | ||
| 75 | + var beginDragOffset: CGFloat = 0.0 | ||
| 17 | 76 | ||
| 77 | + ///颜色管理 | ||
| 18 | var colorChange: WJColorChange! | 78 | var colorChange: WJColorChange! |
| 19 | 79 | ||
| 20 | ///代理 | 80 | ///代理 |
| @@ -79,31 +139,47 @@ class CNCustomIndexView:PGIndexBannerSubiew, UIScrollViewDelegate, WJColorChange | @@ -79,31 +139,47 @@ class CNCustomIndexView:PGIndexBannerSubiew, UIScrollViewDelegate, WJColorChange | ||
| 79 | ///收钱view | 139 | ///收钱view |
| 80 | lazy var collectMoneyCodeView: CNCollectMoneyCodeView = { | 140 | lazy var collectMoneyCodeView: CNCollectMoneyCodeView = { |
| 81 | 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 | ||
| 143 | + self?.baseScrollView.setContentOffset(CGPoint(x: 0, y: (self!.baseScrollView.height)), animated: true) | ||
| 144 | + } | ||
| 82 | return collectionView | 145 | return collectionView |
| 83 | }() | 146 | }() |
| 84 | 147 | ||
| 85 | ///付钱view | 148 | ///付钱view |
| 86 | lazy var payMoneyCodeView : CNPayMoneyCodeView = { | 149 | lazy var payMoneyCodeView : CNPayMoneyCodeView = { |
| 87 | - 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)) |
| 88 | 151 | ||
| 89 | return payMoneyCodeView | 152 | return payMoneyCodeView |
| 90 | }() | 153 | }() |
| 91 | 154 | ||
| 92 | - ///底部付钱提前view | 155 | + ///上滑付钱提醒view |
| 93 | lazy var bottomPayMoneyRemindView: CNBottomPayMoneyRemindView = { | 156 | lazy var bottomPayMoneyRemindView: CNBottomPayMoneyRemindView = { |
| 94 | let W: CGFloat = UIScreen.main.bounds.width-100 | 157 | let W: CGFloat = UIScreen.main.bounds.width-100 |
| 95 | - 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)) | ||
| 96 | bottomView.backgroundColor = UIColor.clear | 160 | bottomView.backgroundColor = UIColor.clear |
| 97 | return bottomView | 161 | return bottomView |
| 98 | }() | 162 | }() |
| 99 | - /// 顶部收钱提前view | 163 | + /// 下滑收钱提醒view |
| 100 | lazy var topCollectMoneyRemindView:CNTopCollectMoneyRemindView = { | 164 | lazy var topCollectMoneyRemindView:CNTopCollectMoneyRemindView = { |
| 101 | let W: CGFloat = UIScreen.main.bounds.width-100 | 165 | let W: CGFloat = UIScreen.main.bounds.width-100 |
| 102 | - let topView = CNTopCollectMoneyRemindView.init(frame: CGRectMake(25, self.baseScrollView.height-W/2, W,W/2)) | ||
| 103 | - 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 | + | ||
| 104 | return topView | 170 | return topView |
| 105 | }() | 171 | }() |
| 106 | 172 | ||
| 173 | + /// 顶部自定义导航 | ||
| 174 | + lazy var topNavView: CNCustomIndexTopView = { | ||
| 175 | + let topNavView = CNCustomIndexTopView.init(frame: CGRect(x: 0, y: 0, width: self.width, height: KNavigationHeight)) | ||
| 176 | + topNavView.alpha = 0 | ||
| 177 | + topNavView.closeAction = { [weak self ] in | ||
| 178 | + self!.baseScrollView.setContentOffset(CGPoint(x: 0, y: self!.baseScrollView.height), animated: true) | ||
| 179 | + } | ||
| 180 | + return topNavView | ||
| 181 | + }() | ||
| 182 | + | ||
| 107 | // MARK: - 初始化方法 | 183 | // MARK: - 初始化方法 |
| 108 | override init(frame: CGRect) { | 184 | override init(frame: CGRect) { |
| 109 | super.init(frame: frame) | 185 | super.init(frame: frame) |
| @@ -116,13 +192,16 @@ class CNCustomIndexView:PGIndexBannerSubiew, UIScrollViewDelegate, WJColorChange | @@ -116,13 +192,16 @@ class CNCustomIndexView:PGIndexBannerSubiew, UIScrollViewDelegate, WJColorChange | ||
| 116 | 192 | ||
| 117 | // MARK: - 添加UI | 193 | // MARK: - 添加UI |
| 118 | func initUI(){ | 194 | func initUI(){ |
| 119 | - self.addSubview(self.baseScrollView) | ||
| 120 | - self.baseScrollView.addSubview(self.collectMoneyCodeView) | 195 | + self.addSubview(self.bottomPayMoneyRemindView) |
| 196 | + self.addSubview(self.topCollectMoneyRemindView) | ||
| 197 | + | ||
| 198 | + self.addSubview(self.baseScrollView) | ||
| 199 | + self.addSubview(self.topNavView) | ||
| 200 | + self.topNavView.setTitleString(title: "志愿者") | ||
| 121 | 201 | ||
| 202 | + self.baseScrollView.addSubview(self.collectMoneyCodeView) | ||
| 122 | self.baseScrollView.addSubview(self.mainView) | 203 | self.baseScrollView.addSubview(self.mainView) |
| 123 | self.baseScrollView.addSubview(self.payMoneyCodeView) | 204 | self.baseScrollView.addSubview(self.payMoneyCodeView) |
| 124 | - self.baseScrollView.addSubview(self.bottomPayMoneyRemindView) | ||
| 125 | - self.baseScrollView.addSubview(self.topCollectMoneyRemindView) | ||
| 126 | 205 | ||
| 127 | //默认偏移到中间 | 206 | //默认偏移到中间 |
| 128 | self.baseScrollView.setContentOffset(CGPointMake(0, self.frame.size.height), animated: false) | 207 | self.baseScrollView.setContentOffset(CGPointMake(0, self.frame.size.height), animated: false) |
| @@ -148,6 +227,19 @@ class CNCustomIndexView:PGIndexBannerSubiew, UIScrollViewDelegate, WJColorChange | @@ -148,6 +227,19 @@ class CNCustomIndexView:PGIndexBannerSubiew, UIScrollViewDelegate, WJColorChange | ||
| 148 | } | 227 | } |
| 149 | 228 | ||
| 150 | // MARK: - WJColorChange代理 | 229 | // MARK: - WJColorChange代理 |
| 230 | + ///将要开始拖拽滚动 | ||
| 231 | + func wjColorScrollViewWillBeginDragging(_ scrollView: UIScrollView!) { | ||
| 232 | + | ||
| 233 | + self.beginDragOffset = scrollView.contentOffset.y | ||
| 234 | + | ||
| 235 | + self.delegate?.customIndexViewWillBeiginScroll(scrollView: scrollView) | ||
| 236 | + | ||
| 237 | + //开始滑动把 baseScrollView 放到导航的上层 | ||
| 238 | + self.bringSubviewToFront(self.baseScrollView) | ||
| 239 | + | ||
| 240 | + | ||
| 241 | + } | ||
| 242 | + | ||
| 151 | ///WJColorChange 代理方法 滚动时候回调 传出当前的滚动视图 | 243 | ///WJColorChange 代理方法 滚动时候回调 传出当前的滚动视图 |
| 152 | func wjColorScrollViewScroll(_ scrollView: UIScrollView!) { | 244 | func wjColorScrollViewScroll(_ scrollView: UIScrollView!) { |
| 153 | 245 | ||
| @@ -170,30 +262,34 @@ class CNCustomIndexView:PGIndexBannerSubiew, UIScrollViewDelegate, WJColorChange | @@ -170,30 +262,34 @@ class CNCustomIndexView:PGIndexBannerSubiew, UIScrollViewDelegate, WJColorChange | ||
| 170 | rightView?.alpha = (70-fabsOffset)/70.00 | 262 | rightView?.alpha = (70-fabsOffset)/70.00 |
| 171 | } | 263 | } |
| 172 | 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 | + } | ||
| 173 | //上滑滑动到临近值,让bottomPayMoneyRemindView位置一直停留在底部,并慢慢消失 | 269 | //上滑滑动到临近值,让bottomPayMoneyRemindView位置一直停留在底部,并慢慢消失 |
| 174 | - let bottomPayMoneyRemindViewMaxOffset: CGFloat = self.baseScrollView.height+self.bottomPayMoneyRemindView.height | ||
| 175 | - if (currentOffset > bottomPayMoneyRemindViewMaxOffset) { | 270 | + if (self.bottomPayMoneyRemindView.top < self.height - self.bottomPayMoneyRemindView.height) { |
| 176 | /**让bottomPayMoneyRemindView位置一直停留在底部*/ | 271 | /**让bottomPayMoneyRemindView位置一直停留在底部*/ |
| 177 | - self.bottomPayMoneyRemindView.top = currentOffset+self.baseScrollView.height-self.bottomPayMoneyRemindView.height | 272 | + self.bottomPayMoneyRemindView.top = self.height - self.bottomPayMoneyRemindView.height |
| 178 | 273 | ||
| 179 | - /**渐渐隐藏bottomPayMoneyRemindView,缓冲距离为40*/ | ||
| 180 | - 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 | ||
| 181 | 277 | ||
| 182 | - //让系统及时更新bottomPayMoneyRemindView | ||
| 183 | -// self.bottomPayMoneyRemindView.setNeedsLayout() | ||
| 184 | -// self.bottomPayMoneyRemindView.layoutIfNeeded() | ||
| 185 | } | 278 | } |
| 186 | 279 | ||
| 187 | - //下滑滑动到临近值,让topCollectMoneyRemindView位置一直停留在底部,并慢慢消失 | ||
| 188 | - let topCollectMoneyRemindViewMinOffset: CGFloat = self.baseScrollView.height-self.topCollectMoneyRemindView.height | ||
| 189 | - 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 | + | ||
| 190 | /**让topCollectMoneyRemindView位置一直停留在底部*/ | 287 | /**让topCollectMoneyRemindView位置一直停留在底部*/ |
| 191 | - self.topCollectMoneyRemindView.bottom = currentOffset+self.topCollectMoneyRemindView.height | 288 | + self.topCollectMoneyRemindView.bottom = self.topCollectMoneyRemindView.height |
| 192 | 289 | ||
| 193 | - /**渐渐隐藏topCollectMoneyRemindView,缓冲距离为40*/ | ||
| 194 | - print("currentOffset =", topCollectMoneyRemindViewMinOffset - currentOffset) | ||
| 195 | - | ||
| 196 | - 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 | ||
| 197 | 293 | ||
| 198 | //让系统及时更新topCollectMoneyRemindView | 294 | //让系统及时更新topCollectMoneyRemindView |
| 199 | // self.topCollectMoneyRemindView.setNeedsLayout() | 295 | // self.topCollectMoneyRemindView.setNeedsLayout() |
| @@ -218,6 +314,20 @@ class CNCustomIndexView:PGIndexBannerSubiew, UIScrollViewDelegate, WJColorChange | @@ -218,6 +314,20 @@ class CNCustomIndexView:PGIndexBannerSubiew, UIScrollViewDelegate, WJColorChange | ||
| 218 | // self.mainView.scaledView(scale: scale) | 314 | // self.mainView.scaledView(scale: scale) |
| 219 | // } | 315 | // } |
| 220 | 316 | ||
| 317 | + /**隐藏顶部导航**/ | ||
| 318 | + let topNavViewAlpha: CGFloat = 1.0 - (self.baseScrollView.height * 2 - currentOffset)/(self.baseScrollView.height*0.5) | ||
| 319 | + if(topNavViewAlpha > 0){ | ||
| 320 | + self.topNavView.alpha = topNavViewAlpha | ||
| 321 | + } | ||
| 322 | + else{ | ||
| 323 | + self.topNavView.alpha = 0 | ||
| 324 | + } | ||
| 325 | + | ||
| 326 | + //隐藏collectMoneyCodeView的bottomView | ||
| 327 | + if scrollView.contentOffset.y > 10{ | ||
| 328 | + self.collectMoneyCodeView.bottomView.isHidden = true | ||
| 329 | + self.collectMoneyCodeView.contentView.backgroundColor = .clear | ||
| 330 | + } | ||
| 221 | 331 | ||
| 222 | delegate?.customIndexViewDidScroll(scrollView: self.baseScrollView) | 332 | delegate?.customIndexViewDidScroll(scrollView: self.baseScrollView) |
| 223 | 333 | ||
| @@ -239,7 +349,24 @@ class CNCustomIndexView:PGIndexBannerSubiew, UIScrollViewDelegate, WJColorChange | @@ -239,7 +349,24 @@ class CNCustomIndexView:PGIndexBannerSubiew, UIScrollViewDelegate, WJColorChange | ||
| 239 | else{ | 349 | else{ |
| 240 | self.superScrollView?.isScrollEnabled = false | 350 | self.superScrollView?.isScrollEnabled = false |
| 241 | } | 351 | } |
| 242 | - | 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 | + //外部代理 | ||
| 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) | ||
| 243 | } | 370 | } |
| 244 | 371 | ||
| 245 | } | 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,7 +47,7 @@ class CNFrontMainView : UIView{ | ||
| 47 | lazy var contentView : UIView = { | 47 | lazy var contentView : UIView = { |
| 48 | 48 | ||
| 49 | let contentView = UIView.init(frame: CGRect(x: 0, y: 0, width: self.width, height: self.height )) | 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 | contentView.clipsToBounds = true | 51 | contentView.clipsToBounds = true |
| 52 | contentView.layer.cornerRadius = 20 | 52 | contentView.layer.cornerRadius = 20 |
| 53 | 53 | ||
| @@ -105,7 +105,7 @@ class CNBackMainView : UIView{ | @@ -105,7 +105,7 @@ class CNBackMainView : UIView{ | ||
| 105 | bottomBackBtn.setTitleColor(UIColor("#333333"), for: .normal) | 105 | bottomBackBtn.setTitleColor(UIColor("#333333"), for: .normal) |
| 106 | bottomBackBtn.setImage(UIImage(named: "homePage_backBtn_icon"), for: .normal) | 106 | bottomBackBtn.setImage(UIImage(named: "homePage_backBtn_icon"), for: .normal) |
| 107 | bottomBackBtn.imageEdgeInsets = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 8) | 107 | bottomBackBtn.imageEdgeInsets = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 8) |
| 108 | - bottomBackBtn.titleLabel?.font = UIFont(name: "KohinoorTelugu-Regular", size: 15) | 108 | + bottomBackBtn.titleLabel?.font = UIFont.systemFont(ofSize: 15, weight: .regular) |
| 109 | 109 | ||
| 110 | bottomBackBtn.addTarget(self, action: #selector(tapAction), for: .touchUpInside) | 110 | bottomBackBtn.addTarget(self, action: #selector(tapAction), for: .touchUpInside) |
| 111 | return bottomBackBtn | 111 | return bottomBackBtn |
metaCode/Classes/Main/HomePage/View/CNPayMoneyCodeView.swift
| @@ -26,10 +26,10 @@ class CNPayMoneyCodeView:UIView{ | @@ -26,10 +26,10 @@ class CNPayMoneyCodeView:UIView{ | ||
| 26 | self.clipsToBounds = true; | 26 | self.clipsToBounds = true; |
| 27 | self.layer.cornerRadius = 20; | 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,17 +40,20 @@ class CNTopCollectMoneyRemindView : UIView{ | ||
| 40 | 40 | ||
| 41 | let bottomShapeLayer = CAShapeLayer() | 41 | let bottomShapeLayer = CAShapeLayer() |
| 42 | bottomShapeLayer.path = bottomCircle.cgPath | 42 | bottomShapeLayer.path = bottomCircle.cgPath |
| 43 | - bottomShapeLayer.fillColor = UIColor("#FCE0E0")?.cgColor | 43 | + bottomShapeLayer.fillColor = UIColor("#F0F5FD")?.cgColor |
| 44 | self.layer.addSublayer(bottomShapeLayer) | 44 | self.layer.addSublayer(bottomShapeLayer) |
| 45 | 45 | ||
| 46 | let btn = UIButton(type: .custom) | 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 | btn.titleLabel?.font = UIFont(name: "KohinoorTelugu-Regular", size: 17) | 50 | btn.titleLabel?.font = UIFont(name: "KohinoorTelugu-Regular", size: 17) |
| 51 | btn.isUserInteractionEnabled = false | 51 | btn.isUserInteractionEnabled = false |
| 52 | - | ||
| 53 | self.addSubview(btn) | 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/Vendors/WJColorChange.h
| @@ -10,7 +10,11 @@ | @@ -10,7 +10,11 @@ | ||
| 10 | 10 | ||
| 11 | 11 | ||
| 12 | @protocol WJColorChangeDelegate <NSObject> | 12 | @protocol WJColorChangeDelegate <NSObject> |
| 13 | - | 13 | +/** |
| 14 | + 将要开始拖拽滚动 | ||
| 15 | + @param scrollView 滚动视图 | ||
| 16 | + */ | ||
| 17 | +- (void)WJColorScrollViewWillBeginDragging:(UIScrollView *)scrollView; | ||
| 14 | 18 | ||
| 15 | /** | 19 | /** |
| 16 | 滚动时候回调 传出当前的滚动视图 | 20 | 滚动时候回调 传出当前的滚动视图 |
metaCode/Classes/Vendors/WJColorChange.m
| @@ -123,8 +123,13 @@ | @@ -123,8 +123,13 @@ | ||
| 123 | - (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView | 123 | - (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView |
| 124 | { | 124 | { |
| 125 | _startOffsetY = scrollView.contentOffset.y; | 125 | _startOffsetY = scrollView.contentOffset.y; |
| 126 | + if ([self.delegate respondsToSelector:@selector(WJColorScrollViewWillBeginDragging:)]) { | ||
| 127 | + | ||
| 128 | + [self.delegate WJColorScrollViewWillBeginDragging:scrollView]; | ||
| 129 | + } | ||
| 126 | } | 130 | } |
| 127 | 131 | ||
| 132 | + | ||
| 128 | - (void)scrollViewDidScroll:(UIScrollView *)scrollView { | 133 | - (void)scrollViewDidScroll:(UIScrollView *)scrollView { |
| 129 | 134 | ||
| 130 | 135 |
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_close_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_close_icon.imageset/关闭@2x.png
0 → 100644
422 Bytes
metaCode/Supporting Files/Assets.xcassets/Home/homePage_close_icon.imageset/关闭@3x.png
0 → 100644
693 Bytes
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