Commit 16738b0064e152b89c7e1069167597c7eb7143de
1 parent
5caacf8a
添加tabBar
Showing
45 changed files
with
577 additions
and
88 deletions
metaCode.xcodeproj/project.pbxproj
| @@ -10,12 +10,14 @@ | @@ -10,12 +10,14 @@ | ||
| 10 | 0D39E93D7229931C86EB1161 /* Pods_metaCode_metaCodeUITests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 63D879B49B1E42F1584DD75E /* Pods_metaCode_metaCodeUITests.framework */; }; | 10 | 0D39E93D7229931C86EB1161 /* Pods_metaCode_metaCodeUITests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 63D879B49B1E42F1584DD75E /* Pods_metaCode_metaCodeUITests.framework */; }; |
| 11 | 1DD2808DF02C120276F99F4D /* Pods_metaCode.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F1C55A719CFEE073C06D37CE /* Pods_metaCode.framework */; }; | 11 | 1DD2808DF02C120276F99F4D /* Pods_metaCode.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F1C55A719CFEE073C06D37CE /* Pods_metaCode.framework */; }; |
| 12 | 790D01822A2D88FC00C5978D /* CNLiveConfigMacro.swift in Sources */ = {isa = PBXBuildFile; fileRef = 790D01812A2D88FC00C5978D /* CNLiveConfigMacro.swift */; }; | 12 | 790D01822A2D88FC00C5978D /* CNLiveConfigMacro.swift in Sources */ = {isa = PBXBuildFile; fileRef = 790D01812A2D88FC00C5978D /* CNLiveConfigMacro.swift */; }; |
| 13 | - 790D01852A2D89E100C5978D /* CNHexColor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 790D01842A2D89E100C5978D /* CNHexColor.swift */; }; | ||
| 14 | - 796398932A260C0100D045EB /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7963988C2A260C0100D045EB /* ViewController.swift */; }; | 13 | + 790D01852A2D89E100C5978D /* UIColor+CNHexColor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 790D01842A2D89E100C5978D /* UIColor+CNHexColor.swift */; }; |
| 14 | + 796398932A260C0100D045EB /* CNMineViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7963988C2A260C0100D045EB /* CNMineViewController.swift */; }; | ||
| 15 | 796398942A260C0100D045EB /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7963988D2A260C0100D045EB /* AppDelegate.swift */; }; | 15 | 796398942A260C0100D045EB /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7963988D2A260C0100D045EB /* AppDelegate.swift */; }; |
| 16 | 7963989D2A260E6200D045EB /* CNLiveBaseViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7963989C2A260E6200D045EB /* CNLiveBaseViewController.swift */; }; | 16 | 7963989D2A260E6200D045EB /* CNLiveBaseViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7963989C2A260E6200D045EB /* CNLiveBaseViewController.swift */; }; |
| 17 | 79A68C4A2A26E6CE00DC3B43 /* (null) in Sources */ = {isa = PBXBuildFile; }; | 17 | 79A68C4A2A26E6CE00DC3B43 /* (null) in Sources */ = {isa = PBXBuildFile; }; |
| 18 | 79A68C4C2A26EA6000DC3B43 /* (null) in Sources */ = {isa = PBXBuildFile; }; | 18 | 79A68C4C2A26EA6000DC3B43 /* (null) in Sources */ = {isa = PBXBuildFile; }; |
| 19 | + 7C4931292A2D8BA8000E44B4 /* CNLiveBaseTabBarViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7C4931282A2D8BA8000E44B4 /* CNLiveBaseTabBarViewController.swift */; }; | ||
| 20 | + 7C49312D2A2DB9FA000E44B4 /* UITabBar+CNBadge.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7C49312C2A2DB9FA000E44B4 /* UITabBar+CNBadge.swift */; }; | ||
| 19 | 7CD675292A270F6A008354C1 /* WJColorChange.m in Sources */ = {isa = PBXBuildFile; fileRef = 7CD675282A270F6A008354C1 /* WJColorChange.m */; }; | 21 | 7CD675292A270F6A008354C1 /* WJColorChange.m in Sources */ = {isa = PBXBuildFile; fileRef = 7CD675282A270F6A008354C1 /* WJColorChange.m */; }; |
| 20 | 7CD6753C2A2740B0008354C1 /* CNBottomPayMoneyRemindView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7CD675372A2740B0008354C1 /* CNBottomPayMoneyRemindView.swift */; }; | 22 | 7CD6753C2A2740B0008354C1 /* CNBottomPayMoneyRemindView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7CD675372A2740B0008354C1 /* CNBottomPayMoneyRemindView.swift */; }; |
| 21 | 7CD6753D2A2740B0008354C1 /* CNMainView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7CD675382A2740B0008354C1 /* CNMainView.swift */; }; | 23 | 7CD6753D2A2740B0008354C1 /* CNMainView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7CD675382A2740B0008354C1 /* CNMainView.swift */; }; |
| @@ -61,11 +63,13 @@ | @@ -61,11 +63,13 @@ | ||
| 61 | 67F8190701D1AB7F7724E8BA /* Pods-metaCodeTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-metaCodeTests.release.xcconfig"; path = "Target Support Files/Pods-metaCodeTests/Pods-metaCodeTests.release.xcconfig"; sourceTree = "<group>"; }; | 63 | 67F8190701D1AB7F7724E8BA /* Pods-metaCodeTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-metaCodeTests.release.xcconfig"; path = "Target Support Files/Pods-metaCodeTests/Pods-metaCodeTests.release.xcconfig"; sourceTree = "<group>"; }; |
| 62 | 721865F548C997EFAE525B6F /* Pods-metaCode-metaCodeUITests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-metaCode-metaCodeUITests.release.xcconfig"; path = "Target Support Files/Pods-metaCode-metaCodeUITests/Pods-metaCode-metaCodeUITests.release.xcconfig"; sourceTree = "<group>"; }; | 64 | 721865F548C997EFAE525B6F /* Pods-metaCode-metaCodeUITests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-metaCode-metaCodeUITests.release.xcconfig"; path = "Target Support Files/Pods-metaCode-metaCodeUITests/Pods-metaCode-metaCodeUITests.release.xcconfig"; sourceTree = "<group>"; }; |
| 63 | 790D01812A2D88FC00C5978D /* CNLiveConfigMacro.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CNLiveConfigMacro.swift; sourceTree = "<group>"; }; | 65 | 790D01812A2D88FC00C5978D /* CNLiveConfigMacro.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CNLiveConfigMacro.swift; sourceTree = "<group>"; }; |
| 64 | - 790D01842A2D89E100C5978D /* CNHexColor.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CNHexColor.swift; sourceTree = "<group>"; }; | ||
| 65 | - 7963988C2A260C0100D045EB /* ViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = "<group>"; }; | 66 | + 790D01842A2D89E100C5978D /* UIColor+CNHexColor.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UIColor+CNHexColor.swift"; sourceTree = "<group>"; }; |
| 67 | + 7963988C2A260C0100D045EB /* CNMineViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CNMineViewController.swift; sourceTree = "<group>"; }; | ||
| 66 | 7963988D2A260C0100D045EB /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; }; | 68 | 7963988D2A260C0100D045EB /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; }; |
| 67 | 7963989C2A260E6200D045EB /* CNLiveBaseViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CNLiveBaseViewController.swift; sourceTree = "<group>"; }; | 69 | 7963989C2A260E6200D045EB /* CNLiveBaseViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CNLiveBaseViewController.swift; sourceTree = "<group>"; }; |
| 68 | 79A68C512A26F59C00DC3B43 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = metaCode/Info.plist; sourceTree = "<group>"; }; | 70 | 79A68C512A26F59C00DC3B43 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = metaCode/Info.plist; sourceTree = "<group>"; }; |
| 71 | + 7C4931282A2D8BA8000E44B4 /* CNLiveBaseTabBarViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNLiveBaseTabBarViewController.swift; sourceTree = "<group>"; }; | ||
| 72 | + 7C49312C2A2DB9FA000E44B4 /* UITabBar+CNBadge.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UITabBar+CNBadge.swift"; sourceTree = "<group>"; }; | ||
| 69 | 7CD675262A270F69008354C1 /* metaCode-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "metaCode-Bridging-Header.h"; sourceTree = "<group>"; }; | 73 | 7CD675262A270F69008354C1 /* metaCode-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "metaCode-Bridging-Header.h"; sourceTree = "<group>"; }; |
| 70 | 7CD675272A270F6A008354C1 /* WJColorChange.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WJColorChange.h; sourceTree = "<group>"; }; | 74 | 7CD675272A270F6A008354C1 /* WJColorChange.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WJColorChange.h; sourceTree = "<group>"; }; |
| 71 | 7CD675282A270F6A008354C1 /* WJColorChange.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WJColorChange.m; sourceTree = "<group>"; }; | 75 | 7CD675282A270F6A008354C1 /* WJColorChange.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WJColorChange.m; sourceTree = "<group>"; }; |
| @@ -139,7 +143,8 @@ | @@ -139,7 +143,8 @@ | ||
| 139 | 790D01832A2D89E100C5978D /* Extensions */ = { | 143 | 790D01832A2D89E100C5978D /* Extensions */ = { |
| 140 | isa = PBXGroup; | 144 | isa = PBXGroup; |
| 141 | children = ( | 145 | children = ( |
| 142 | - 790D01842A2D89E100C5978D /* CNHexColor.swift */, | 146 | + 790D01842A2D89E100C5978D /* UIColor+CNHexColor.swift */, |
| 147 | + 7C49312C2A2DB9FA000E44B4 /* UITabBar+CNBadge.swift */, | ||
| 143 | ); | 148 | ); |
| 144 | path = Extensions; | 149 | path = Extensions; |
| 145 | sourceTree = "<group>"; | 150 | sourceTree = "<group>"; |
| @@ -162,7 +167,6 @@ | @@ -162,7 +167,6 @@ | ||
| 162 | 7963988B2A260C0100D045EB /* Other */ = { | 167 | 7963988B2A260C0100D045EB /* Other */ = { |
| 163 | isa = PBXGroup; | 168 | isa = PBXGroup; |
| 164 | children = ( | 169 | children = ( |
| 165 | - 7963988C2A260C0100D045EB /* ViewController.swift */, | ||
| 166 | 7963988D2A260C0100D045EB /* AppDelegate.swift */, | 170 | 7963988D2A260C0100D045EB /* AppDelegate.swift */, |
| 167 | ); | 171 | ); |
| 168 | path = Other; | 172 | path = Other; |
| @@ -192,6 +196,7 @@ | @@ -192,6 +196,7 @@ | ||
| 192 | 796398902A260C0100D045EB /* Main */ = { | 196 | 796398902A260C0100D045EB /* Main */ = { |
| 193 | isa = PBXGroup; | 197 | isa = PBXGroup; |
| 194 | children = ( | 198 | children = ( |
| 199 | + 7C49312E2A2DBCB4000E44B4 /* Mine */, | ||
| 195 | 7CD675212A26F844008354C1 /* HomePage */, | 200 | 7CD675212A26F844008354C1 /* HomePage */, |
| 196 | ); | 201 | ); |
| 197 | path = Main; | 202 | path = Main; |
| @@ -227,10 +232,27 @@ | @@ -227,10 +232,27 @@ | ||
| 227 | isa = PBXGroup; | 232 | isa = PBXGroup; |
| 228 | children = ( | 233 | children = ( |
| 229 | 7963989C2A260E6200D045EB /* CNLiveBaseViewController.swift */, | 234 | 7963989C2A260E6200D045EB /* CNLiveBaseViewController.swift */, |
| 235 | + 7C4931282A2D8BA8000E44B4 /* CNLiveBaseTabBarViewController.swift */, | ||
| 230 | ); | 236 | ); |
| 231 | path = Base; | 237 | path = Base; |
| 232 | sourceTree = "<group>"; | 238 | sourceTree = "<group>"; |
| 233 | }; | 239 | }; |
| 240 | + 7C49312E2A2DBCB4000E44B4 /* Mine */ = { | ||
| 241 | + isa = PBXGroup; | ||
| 242 | + children = ( | ||
| 243 | + 7C49312F2A2DBCC4000E44B4 /* Controller */, | ||
| 244 | + ); | ||
| 245 | + path = Mine; | ||
| 246 | + sourceTree = "<group>"; | ||
| 247 | + }; | ||
| 248 | + 7C49312F2A2DBCC4000E44B4 /* Controller */ = { | ||
| 249 | + isa = PBXGroup; | ||
| 250 | + children = ( | ||
| 251 | + 7963988C2A260C0100D045EB /* CNMineViewController.swift */, | ||
| 252 | + ); | ||
| 253 | + path = Controller; | ||
| 254 | + sourceTree = "<group>"; | ||
| 255 | + }; | ||
| 234 | 7CD675212A26F844008354C1 /* HomePage */ = { | 256 | 7CD675212A26F844008354C1 /* HomePage */ = { |
| 235 | isa = PBXGroup; | 257 | isa = PBXGroup; |
| 236 | children = ( | 258 | children = ( |
| @@ -582,11 +604,13 @@ | @@ -582,11 +604,13 @@ | ||
| 582 | 7CD6754F2A2840B9008354C1 /* CNMetaCodeHomePageController.swift in Sources */, | 604 | 7CD6754F2A2840B9008354C1 /* CNMetaCodeHomePageController.swift in Sources */, |
| 583 | 7CD675472A274167008354C1 /* NewPagedFlowView.m in Sources */, | 605 | 7CD675472A274167008354C1 /* NewPagedFlowView.m in Sources */, |
| 584 | 79A68C4A2A26E6CE00DC3B43 /* (null) in Sources */, | 606 | 79A68C4A2A26E6CE00DC3B43 /* (null) in Sources */, |
| 585 | - 790D01852A2D89E100C5978D /* CNHexColor.swift in Sources */, | ||
| 586 | - 796398932A260C0100D045EB /* ViewController.swift in Sources */, | 607 | + 790D01852A2D89E100C5978D /* UIColor+CNHexColor.swift in Sources */, |
| 608 | + 796398932A260C0100D045EB /* CNMineViewController.swift in Sources */, | ||
| 587 | 7CD675422A2740F8008354C1 /* CNCustomIndexView.swift in Sources */, | 609 | 7CD675422A2740F8008354C1 /* CNCustomIndexView.swift in Sources */, |
| 610 | + 7C4931292A2D8BA8000E44B4 /* CNLiveBaseTabBarViewController.swift in Sources */, | ||
| 588 | 7CD6753F2A2740B0008354C1 /* CNTopCollectMoneyRemindView.swift in Sources */, | 611 | 7CD6753F2A2740B0008354C1 /* CNTopCollectMoneyRemindView.swift in Sources */, |
| 589 | 7CD6753C2A2740B0008354C1 /* CNBottomPayMoneyRemindView.swift in Sources */, | 612 | 7CD6753C2A2740B0008354C1 /* CNBottomPayMoneyRemindView.swift in Sources */, |
| 613 | + 7C49312D2A2DB9FA000E44B4 /* UITabBar+CNBadge.swift in Sources */, | ||
| 590 | 79A68C4C2A26EA6000DC3B43 /* (null) in Sources */, | 614 | 79A68C4C2A26EA6000DC3B43 /* (null) in Sources */, |
| 591 | ); | 615 | ); |
| 592 | runOnlyForDeploymentPostprocessing = 0; | 616 | runOnlyForDeploymentPostprocessing = 0; |
metaCode/Classes/Common/Base/CNLiveBaseTabBarViewController.swift
0 → 100644
| 1 | +// | ||
| 2 | +// CNLiveBaseTabbarViewController.swift | ||
| 3 | +// metaCode | ||
| 4 | +// | ||
| 5 | +// Created by daojian on 2023/6/5. | ||
| 6 | +// | ||
| 7 | + | ||
| 8 | +import Foundation | ||
| 9 | +import UIKit | ||
| 10 | + | ||
| 11 | +class CNLiveBaseTabBarViewController:UITabBarController | ||
| 12 | +{ | ||
| 13 | + | ||
| 14 | + override func viewDidLoad() { | ||
| 15 | + super.viewDidLoad() | ||
| 16 | + } | ||
| 17 | + | ||
| 18 | + override func viewWillAppear(_ animated: Bool) { | ||
| 19 | + super.viewWillAppear(animated) | ||
| 20 | + self.setUpTabBar() | ||
| 21 | + self.setupBackgroup() | ||
| 22 | + | ||
| 23 | + } | ||
| 24 | + override func viewDidAppear(_ animated: Bool) { | ||
| 25 | + super.viewDidAppear(animated) | ||
| 26 | + | ||
| 27 | + } | ||
| 28 | + // MARK: - 控制器的信息 | ||
| 29 | + func setUpTabBar() { | ||
| 30 | + | ||
| 31 | + let homeVC = CNMetaCodeHomePageController() | ||
| 32 | + let mineVC = CNMineViewController() | ||
| 33 | + | ||
| 34 | + creatTabbarView(viewController: homeVC, image: "tabbar_hoem_icon_default", selectImage: "tabbar_hoem_icon_selected", title: "首页") | ||
| 35 | + | ||
| 36 | + creatTabbarView(viewController: mineVC, image: "tabbar_mine_icon_default", selectImage: "tabbar_mine_icon_selected", title: "我的") | ||
| 37 | + | ||
| 38 | + self.tabBar.tintColor = UIColor("#0066FE") | ||
| 39 | + self.tabBar.isTranslucent = false | ||
| 40 | + | ||
| 41 | + self.viewControllers = [ | ||
| 42 | + UINavigationController(rootViewController: homeVC), | ||
| 43 | + UINavigationController(rootViewController: mineVC), | ||
| 44 | + ]; | ||
| 45 | + | ||
| 46 | + | ||
| 47 | + } | ||
| 48 | + | ||
| 49 | + // MARK: - Tabar 背景图 | ||
| 50 | + func setupBackgroup(){ | ||
| 51 | + if #available(iOS 13.0, *) { | ||
| 52 | + let appearance: UITabBarAppearance = UITabBarAppearance.init() | ||
| 53 | + appearance.configureWithTransparentBackground() | ||
| 54 | + appearance.backgroundColor = UIColor.clear | ||
| 55 | + appearance.backgroundImage = UIImage(named: "tabbar_backgroup") | ||
| 56 | + if #available(iOS 15.0, *) { | ||
| 57 | + tabBar.scrollEdgeAppearance = appearance | ||
| 58 | + } else { | ||
| 59 | + // Fallback on earlier versions | ||
| 60 | + tabBar.standardAppearance = appearance | ||
| 61 | + } | ||
| 62 | + | ||
| 63 | + } else { | ||
| 64 | + tabBar.backgroundColor = .clear | ||
| 65 | + tabBar.backgroundImage = UIImage(named: "tabbar_backgroup") | ||
| 66 | + } | ||
| 67 | + } | ||
| 68 | + | ||
| 69 | + // MARK: - TabBar里面的文字图片 | ||
| 70 | + func creatTabbarView(viewController:UIViewController, image:NSString, selectImage:NSString, title:NSString) { | ||
| 71 | + // alwaysOriginal 始终绘制图片原始状态,不使用Tint Color。 | ||
| 72 | + viewController.tabBarItem.image = UIImage(named: image as String)?.withRenderingMode(.alwaysOriginal) | ||
| 73 | + viewController.tabBarItem.selectedImage = UIImage(named: selectImage as String)?.withRenderingMode(.alwaysOriginal) | ||
| 74 | + viewController.title = title as String | ||
| 75 | + } | ||
| 76 | +} | ||
| 77 | + |
metaCode/Classes/Common/Base/CNLiveBaseViewController.swift
| @@ -19,6 +19,9 @@ class CNLiveBaseViewController: UIViewController { | @@ -19,6 +19,9 @@ class CNLiveBaseViewController: UIViewController { | ||
| 19 | 19 | ||
| 20 | configIOS11() | 20 | configIOS11() |
| 21 | configIOS15() | 21 | configIOS15() |
| 22 | + | ||
| 23 | + self.navigationController?.isNavigationBarHidden = true | ||
| 24 | + | ||
| 22 | } | 25 | } |
| 23 | 26 | ||
| 24 | 27 |
metaCode/Classes/Constant/CNLiveConstant.swift
| @@ -19,4 +19,8 @@ let KNavigationHeight = (KStatusBarHeight + 44) | @@ -19,4 +19,8 @@ let KNavigationHeight = (KStatusBarHeight + 44) | ||
| 19 | ///tabbar高度 | 19 | ///tabbar高度 |
| 20 | let KTabBarHeight = (KStatusBarHeight == 44 ? 83 : 49) | 20 | let KTabBarHeight = (KStatusBarHeight == 44 ? 83 : 49) |
| 21 | 21 | ||
| 22 | +//MARK: - 常用背景色 | ||
| 23 | +///控制器背景色 | ||
| 24 | +let KVCBackgroupColor = UIColor("#F9F9F9") | ||
| 25 | + | ||
| 22 | 26 |
metaCode/Classes/Extensions/CNHexColor.swift renamed to metaCode/Classes/Extensions/UIColor+CNHexColor.swift
metaCode/Classes/Extensions/UITabBar+CNBadge.swift
0 → 100644
| 1 | +// | ||
| 2 | +// UITabBar+CNBadge.swift | ||
| 3 | +// metaCode | ||
| 4 | +// | ||
| 5 | +// Created by daojian on 2023/6/5. | ||
| 6 | +// | ||
| 7 | + | ||
| 8 | +import Foundation | ||
| 9 | +import UIKit | ||
| 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 | +} |
metaCode/Classes/Main/HomePage/Controller/CNMetaCodeHomePageController.swift
| @@ -12,7 +12,9 @@ import YYCategories | @@ -12,7 +12,9 @@ import YYCategories | ||
| 12 | let Width: CGFloat = UIScreen.main.bounds.size.width | 12 | let Width: CGFloat = UIScreen.main.bounds.size.width |
| 13 | let Height: CGFloat = UIScreen.main.bounds.size.height | 13 | let Height: CGFloat = UIScreen.main.bounds.size.height |
| 14 | 14 | ||
| 15 | -class CNMetaCodeHomePageController:CNLiveBaseViewController, NewPagedFlowViewDelegate, NewPagedFlowViewDataSource{ | 15 | +class CNMetaCodeHomePageController:CNLiveBaseViewController, NewPagedFlowViewDelegate, NewPagedFlowViewDataSource, CNCustomIndexViewDelegate{ |
| 16 | + | ||
| 17 | + private var tabBarY:CGFloat = 0.0 | ||
| 16 | 18 | ||
| 17 | // MARK: - 懒加载 | 19 | // MARK: - 懒加载 |
| 18 | ///数据源 | 20 | ///数据源 |
| @@ -34,7 +36,7 @@ class CNMetaCodeHomePageController:CNLiveBaseViewController, NewPagedFlowViewDel | @@ -34,7 +36,7 @@ class CNMetaCodeHomePageController:CNLiveBaseViewController, NewPagedFlowViewDel | ||
| 34 | pageFlowView.isOpenAutoScroll = false; | 36 | pageFlowView.isOpenAutoScroll = false; |
| 35 | 37 | ||
| 36 | //左右图片的距离顶部和底部的高度 | 38 | //左右图片的距离顶部和底部的高度 |
| 37 | - pageFlowView.topBottomMargin = 0; | 39 | + pageFlowView.topBottomMargin = 100; |
| 38 | 40 | ||
| 39 | return pageFlowView | 41 | return pageFlowView |
| 40 | 42 | ||
| @@ -44,7 +46,10 @@ class CNMetaCodeHomePageController:CNLiveBaseViewController, NewPagedFlowViewDel | @@ -44,7 +46,10 @@ class CNMetaCodeHomePageController:CNLiveBaseViewController, NewPagedFlowViewDel | ||
| 44 | override func viewDidLoad() { | 46 | override func viewDidLoad() { |
| 45 | super.viewDidLoad() | 47 | super.viewDidLoad() |
| 46 | 48 | ||
| 49 | + self.tabBarY = (self.tabBarController?.tabBar.top)! | ||
| 47 | 50 | ||
| 51 | + self.view.backgroundColor = KVCBackgroupColor | ||
| 52 | + | ||
| 48 | for i in (0..<2) { | 53 | for i in (0..<2) { |
| 49 | self.dataArray.add("122") | 54 | self.dataArray.add("122") |
| 50 | } | 55 | } |
| @@ -75,6 +80,7 @@ class CNMetaCodeHomePageController:CNLiveBaseViewController, NewPagedFlowViewDel | @@ -75,6 +80,7 @@ class CNMetaCodeHomePageController:CNLiveBaseViewController, NewPagedFlowViewDel | ||
| 75 | } | 80 | } |
| 76 | bannerView?.superScrollView = flowView.scrollView; | 81 | bannerView?.superScrollView = flowView.scrollView; |
| 77 | bannerView?.associatedVCView = self.view; | 82 | bannerView?.associatedVCView = self.view; |
| 83 | + bannerView?.delegate = self | ||
| 78 | return bannerView; | 84 | return bannerView; |
| 79 | } | 85 | } |
| 80 | 86 | ||
| @@ -82,4 +88,10 @@ class CNMetaCodeHomePageController:CNLiveBaseViewController, NewPagedFlowViewDel | @@ -82,4 +88,10 @@ class CNMetaCodeHomePageController:CNLiveBaseViewController, NewPagedFlowViewDel | ||
| 82 | return CGSize(width: Width-50, height: Height) | 88 | return CGSize(width: Width-50, height: Height) |
| 83 | } | 89 | } |
| 84 | 90 | ||
| 91 | + //MARK: - CNCustomIndexView 代理方法 | ||
| 92 | + func customIndexViewDidScroll(scrollView: UIScrollView) { | ||
| 93 | + let fabsOffset: CGFloat = abs(scrollView.contentOffset.y - KSreenHeight) | ||
| 94 | + self.tabBarController?.tabBar.top = self.tabBarY + fabsOffset | ||
| 95 | + } | ||
| 96 | + | ||
| 85 | } | 97 | } |
metaCode/Classes/Main/HomePage/View/CNCustomIndexView.swift
| @@ -7,22 +7,19 @@ | @@ -7,22 +7,19 @@ | ||
| 7 | 7 | ||
| 8 | import Foundation | 8 | import Foundation |
| 9 | 9 | ||
| 10 | -///关联的控制器的view | ||
| 11 | -//@property (nonatomic, weak)UIView *associatedVCView | ||
| 12 | -// | ||
| 13 | -/////父视图ScrollView | ||
| 14 | -//@property (nonatomic, weak)UIScrollView *superScrollView | ||
| 15 | -/////自己的底部ScrollView,用来装载 | ||
| 16 | -//@property (nonatomic, strong)UIScrollView *baseScrollView | ||
| 17 | -// | ||
| 18 | -//@property (nonatomic, strong)CNMainView *mainView | ||
| 19 | -//@property (nonatomic, strong)CNCollectMoneyCodeView *collectMoneyCodeView | ||
| 20 | -//@property (nonatomic, strong)CNPayMoneyCodeView *payMoneyCodeView | 10 | + |
| 11 | +protocol CNCustomIndexViewDelegate:NSObjectProtocol{ | ||
| 12 | + ///当前scrollView 发送滚动 | ||
| 13 | + func customIndexViewDidScroll(scrollView :UIScrollView); | ||
| 14 | +} | ||
| 21 | 15 | ||
| 22 | class CNCustomIndexView:PGIndexBannerSubiew, UIScrollViewDelegate, WJColorChangeDelegate{ | 16 | class CNCustomIndexView:PGIndexBannerSubiew, UIScrollViewDelegate, WJColorChangeDelegate{ |
| 23 | 17 | ||
| 24 | var colorChange: WJColorChange! | 18 | var colorChange: WJColorChange! |
| 25 | 19 | ||
| 20 | + ///代理 | ||
| 21 | + weak var delegate:CNCustomIndexViewDelegate? | ||
| 22 | + | ||
| 26 | ///关联的控制器的view | 23 | ///关联的控制器的view |
| 27 | weak var associatedVCView:UIView? | 24 | weak var associatedVCView:UIView? |
| 28 | { | 25 | { |
| @@ -44,7 +41,7 @@ class CNCustomIndexView:PGIndexBannerSubiew, UIScrollViewDelegate, WJColorChange | @@ -44,7 +41,7 @@ class CNCustomIndexView:PGIndexBannerSubiew, UIScrollViewDelegate, WJColorChange | ||
| 44 | 41 | ||
| 45 | ///颜色数据 | 42 | ///颜色数据 |
| 46 | lazy var colorDataArr: NSMutableArray = { | 43 | lazy var colorDataArr: NSMutableArray = { |
| 47 | - let colorDataArr = NSMutableArray(array: NSArray(objects: UIColor.black,UIColor.white,UIColor.red)) | 44 | + let colorDataArr = NSMutableArray(array: NSArray(objects: UIColor.white,KVCBackgroupColor!,UIColor("#004FE0")!)) |
| 48 | 45 | ||
| 49 | return colorDataArr | 46 | return colorDataArr |
| 50 | }() | 47 | }() |
| @@ -160,7 +157,7 @@ class CNCustomIndexView:PGIndexBannerSubiew, UIScrollViewDelegate, WJColorChange | @@ -160,7 +157,7 @@ class CNCustomIndexView:PGIndexBannerSubiew, UIScrollViewDelegate, WJColorChange | ||
| 160 | let currentOffset: CGFloat = scrollView.contentOffset.y | 157 | let currentOffset: CGFloat = scrollView.contentOffset.y |
| 161 | 158 | ||
| 162 | /**隐藏左右view*/ | 159 | /**隐藏左右view*/ |
| 163 | - let fabsOffset: CGFloat = fabs(defaultOffset - currentOffset) | 160 | + let fabsOffset: CGFloat = abs(defaultOffset - currentOffset) |
| 164 | 161 | ||
| 165 | let leftView:UIView? = self.superScrollView?.viewWithTag(tag-1) | 162 | let leftView:UIView? = self.superScrollView?.viewWithTag(tag-1) |
| 166 | let rightView:UIView? = self.superScrollView?.viewWithTag(tag+1) | 163 | let rightView:UIView? = self.superScrollView?.viewWithTag(tag+1) |
| @@ -205,21 +202,24 @@ class CNCustomIndexView:PGIndexBannerSubiew, UIScrollViewDelegate, WJColorChange | @@ -205,21 +202,24 @@ class CNCustomIndexView:PGIndexBannerSubiew, UIScrollViewDelegate, WJColorChange | ||
| 205 | 202 | ||
| 206 | 203 | ||
| 207 | /**控制缩放范围在一定范围*/ | 204 | /**控制缩放范围在一定范围*/ |
| 208 | - let mainViewOffset:CGFloat = abs(currentOffset - self.baseScrollView.height) | ||
| 209 | - if (mainViewOffset < 100) { | ||
| 210 | - var scale: CGFloat = 1.0 | ||
| 211 | - | ||
| 212 | - if (currentOffset < self.baseScrollView.height) { | ||
| 213 | - //下滑时,计算scale方法 | ||
| 214 | - scale = currentOffset/self.baseScrollView.height | ||
| 215 | - } | ||
| 216 | - else { | ||
| 217 | - //上滑时,计算scale方法 | ||
| 218 | - scale = self.baseScrollView.height/currentOffset | ||
| 219 | - } | ||
| 220 | - | ||
| 221 | - self.mainView.scaledView(scale: scale) | ||
| 222 | - } | 205 | +// let mainViewOffset:CGFloat = abs(currentOffset - self.baseScrollView.height) |
| 206 | +// if (mainViewOffset < 100) { | ||
| 207 | +// var scale: CGFloat = 1.0 | ||
| 208 | +// | ||
| 209 | +// if (currentOffset < self.baseScrollView.height) { | ||
| 210 | +// //下滑时,计算scale方法 | ||
| 211 | +// scale = currentOffset/self.baseScrollView.height | ||
| 212 | +// } | ||
| 213 | +// else { | ||
| 214 | +// //上滑时,计算scale方法 | ||
| 215 | +// scale = self.baseScrollView.height/currentOffset | ||
| 216 | +// } | ||
| 217 | +// | ||
| 218 | +// self.mainView.scaledView(scale: scale) | ||
| 219 | +// } | ||
| 220 | + | ||
| 221 | + | ||
| 222 | + delegate?.customIndexViewDidScroll(scrollView: self.baseScrollView) | ||
| 223 | 223 | ||
| 224 | } | 224 | } |
| 225 | 225 |
metaCode/Classes/Main/HomePage/View/CNMainView.swift
| @@ -8,6 +8,9 @@ | @@ -8,6 +8,9 @@ | ||
| 8 | import Foundation | 8 | import Foundation |
| 9 | import YYCategories | 9 | import YYCategories |
| 10 | 10 | ||
| 11 | +///旋转动画时间 | ||
| 12 | +let KTransformAnimationTime:CGFloat = 0.75; | ||
| 13 | +///点击事件回调 | ||
| 11 | typealias closureBlock = ()->Void; | 14 | typealias closureBlock = ()->Void; |
| 12 | 15 | ||
| 13 | ///正面View | 16 | ///正面View |
| @@ -43,14 +46,14 @@ class CNFrontMainView : UIView{ | @@ -43,14 +46,14 @@ class CNFrontMainView : UIView{ | ||
| 43 | 46 | ||
| 44 | lazy var contentView : UIView = { | 47 | lazy var contentView : UIView = { |
| 45 | 48 | ||
| 46 | - let contentView = UIView.init(frame: CGRect(x: 0, y: self.imageView.bottom - 20, width: self.width, height: self.height - self.imageView.bottom + 20)) | ||
| 47 | - contentView.backgroundColor = UIColor.white | 49 | + let contentView = UIView.init(frame: CGRect(x: 0, y: 0, width: self.width, height: self.height )) |
| 50 | + contentView.backgroundColor = UIColor.red | ||
| 48 | contentView.clipsToBounds = true | 51 | contentView.clipsToBounds = true |
| 49 | contentView.layer.cornerRadius = 20 | 52 | contentView.layer.cornerRadius = 20 |
| 50 | 53 | ||
| 51 | - let imageView = UIImageView.init(frame: CGRect(x: 10, y: 10, width: contentView.width - 20, height: contentView.height - 20)) | ||
| 52 | - imageView.image = UIImage.init(named: "homePage_mainView_front"); | ||
| 53 | - contentView.addSubview(imageView) | 54 | +// let imageView = UIImageView.init(frame: CGRect(x: 10, y: 10, width: contentView.width - 20, height: contentView.height - 20)) |
| 55 | +// imageView.image = UIImage.init(named: "homePage_mainView_front"); | ||
| 56 | +// contentView.addSubview(imageView) | ||
| 54 | 57 | ||
| 55 | return contentView | 58 | return contentView |
| 56 | 59 | ||
| @@ -58,16 +61,13 @@ class CNFrontMainView : UIView{ | @@ -58,16 +61,13 @@ class CNFrontMainView : UIView{ | ||
| 58 | 61 | ||
| 59 | func initUI() | 62 | func initUI() |
| 60 | { | 63 | { |
| 61 | - self.addSubview(self.imageView) | 64 | +// self.addSubview(self.imageView) |
| 62 | self.addSubview(self.contentView) | 65 | self.addSubview(self.contentView) |
| 63 | } | 66 | } |
| 64 | 67 | ||
| 65 | @objc func tapAction(){ | 68 | @objc func tapAction(){ |
| 66 | - if (self.tapTransformAciton != nil){ | ||
| 67 | - self.tapTransformAciton | ||
| 68 | - } | 69 | + tapTransformAciton!() |
| 69 | } | 70 | } |
| 70 | - | ||
| 71 | } | 71 | } |
| 72 | 72 | ||
| 73 | ///反面View | 73 | ///反面View |
| @@ -75,17 +75,8 @@ class CNBackMainView : UIView{ | @@ -75,17 +75,8 @@ class CNBackMainView : UIView{ | ||
| 75 | ///点击反转事件 | 75 | ///点击反转事件 |
| 76 | var tapTransformAciton:closureBlock? | 76 | var tapTransformAciton:closureBlock? |
| 77 | 77 | ||
| 78 | - override init(frame: CGRect) { | ||
| 79 | - super.init(frame: frame) | ||
| 80 | - self.initUI() | ||
| 81 | - let tap:UITapGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(tapAction)) | ||
| 82 | - self.addGestureRecognizer(tap) | ||
| 83 | - } | ||
| 84 | - | ||
| 85 | - required init?(coder: NSCoder) { | ||
| 86 | - fatalError("init(coder:) has not been implemented") | ||
| 87 | - } | ||
| 88 | 78 | ||
| 79 | + // MARK: - 懒加载 | ||
| 89 | lazy var imageView:UIImageView = { | 80 | lazy var imageView:UIImageView = { |
| 90 | 81 | ||
| 91 | let tempImageView:UIImageView = UIImageView(frame: CGRect(x: 10, y: 10, width: self.width-20, height: self.height - 20)) | 82 | let tempImageView:UIImageView = UIImageView(frame: CGRect(x: 10, y: 10, width: self.width-20, height: self.height - 20)) |
| @@ -96,7 +87,7 @@ class CNBackMainView : UIView{ | @@ -96,7 +87,7 @@ class CNBackMainView : UIView{ | ||
| 96 | 87 | ||
| 97 | lazy var contentView : UIView = { | 88 | lazy var contentView : UIView = { |
| 98 | 89 | ||
| 99 | - let contentView = UIView.init(frame: CGRect(x: 0, y: self.imageView.bottom - 20, width: self.width, height: self.height-self.imageView.bottom + 20)) | 90 | + let contentView = UIView.init(frame: CGRect(x: 0, y: 0, width: self.width, height: self.height)) |
| 100 | contentView.backgroundColor = UIColor.white | 91 | contentView.backgroundColor = UIColor.white |
| 101 | contentView.clipsToBounds = true | 92 | contentView.clipsToBounds = true |
| 102 | contentView.layer.cornerRadius = 20 | 93 | contentView.layer.cornerRadius = 20 |
| @@ -105,21 +96,45 @@ class CNBackMainView : UIView{ | @@ -105,21 +96,45 @@ class CNBackMainView : UIView{ | ||
| 105 | 96 | ||
| 106 | }() | 97 | }() |
| 107 | 98 | ||
| 99 | + lazy var bottomBackBtn : UIButton = { | ||
| 100 | + let bottomBackBtn = UIButton(type: .custom) | ||
| 101 | + bottomBackBtn.frame = CGRectMake(0, 0, 90, 40) | ||
| 102 | + bottomBackBtn.centerX = self.contentView.width/2 | ||
| 103 | + bottomBackBtn.bottom = self.contentView.height - 15 | ||
| 104 | + bottomBackBtn.setTitle("回到首页", for: .normal) | ||
| 105 | + bottomBackBtn.setTitleColor(UIColor("#333333"), for: .normal) | ||
| 106 | + bottomBackBtn.setImage(UIImage(named: "homePage_backBtn_icon"), for: .normal) | ||
| 107 | + bottomBackBtn.imageEdgeInsets = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 8) | ||
| 108 | + bottomBackBtn.titleLabel?.font = UIFont(name: "KohinoorTelugu-Regular", size: 15) | ||
| 109 | + | ||
| 110 | + bottomBackBtn.addTarget(self, action: #selector(tapAction), for: .touchUpInside) | ||
| 111 | + return bottomBackBtn | ||
| 112 | + }() | ||
| 113 | + //MARK: - 初始化 | ||
| 114 | + override init(frame: CGRect) { | ||
| 115 | + super.init(frame: frame) | ||
| 116 | + self.initUI() | ||
| 117 | + let tap:UITapGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(tapAction)) | ||
| 118 | + self.addGestureRecognizer(tap) | ||
| 119 | + } | ||
| 120 | + | ||
| 121 | + required init?(coder: NSCoder) { | ||
| 122 | + fatalError("init(coder:) has not been implemented") | ||
| 123 | + } | ||
| 124 | + | ||
| 108 | func initUI() | 125 | func initUI() |
| 109 | { | 126 | { |
| 110 | - self.addSubview(self.imageView) | 127 | +// self.addSubview(self.imageView) |
| 111 | self.addSubview(self.contentView) | 128 | self.addSubview(self.contentView) |
| 129 | + self.contentView.addSubview(self.bottomBackBtn) | ||
| 112 | } | 130 | } |
| 113 | - | 131 | + //MARK: - 事件 |
| 114 | @objc func tapAction(){ | 132 | @objc func tapAction(){ |
| 115 | - if (self.tapTransformAciton != nil){ | ||
| 116 | - self.tapTransformAciton | ||
| 117 | - } | 133 | + tapTransformAciton!() |
| 118 | } | 134 | } |
| 119 | } | 135 | } |
| 120 | 136 | ||
| 121 | -///旋转动画时间 | ||
| 122 | -let KTransformAnimationTime:CGFloat = 0.75; | 137 | + |
| 123 | 138 | ||
| 124 | ///中间主VIew | 139 | ///中间主VIew |
| 125 | class CNMainView : UIView{ | 140 | class CNMainView : UIView{ |
| @@ -134,24 +149,18 @@ class CNMainView : UIView{ | @@ -134,24 +149,18 @@ class CNMainView : UIView{ | ||
| 134 | } | 149 | } |
| 135 | 150 | ||
| 136 | lazy var frontView:CNFrontMainView = { | 151 | lazy var frontView:CNFrontMainView = { |
| 137 | -// _frontView = [[CNFrontMainView alloc] initWithFrame:self.bounds]; | ||
| 138 | -// __weak CNMainView *weakSelf = self; | ||
| 139 | -// _frontView.tapTransformAciton = ^{ | ||
| 140 | -// [weakSelf transformToBacnkView]; | ||
| 141 | -// }; | 152 | + |
| 142 | let frontView = CNFrontMainView.init(frame: self.bounds) | 153 | let frontView = CNFrontMainView.init(frame: self.bounds) |
| 143 | - frontView.tapTransformAciton = { | ||
| 144 | - | ||
| 145 | - print("点击了") | 154 | + frontView.tapTransformAciton = { [weak self] in |
| 155 | + self?.transformToBacnkView(); | ||
| 146 | } | 156 | } |
| 147 | return frontView | 157 | return frontView |
| 148 | }() | 158 | }() |
| 149 | 159 | ||
| 150 | lazy var backView:CNBackMainView = { | 160 | lazy var backView:CNBackMainView = { |
| 151 | let backView = CNBackMainView.init(frame: self.bounds) | 161 | let backView = CNBackMainView.init(frame: self.bounds) |
| 152 | - backView.tapTransformAciton = { | ||
| 153 | - | ||
| 154 | - print("点击了") | 162 | + backView.tapTransformAciton = { [weak self] in |
| 163 | + self?.transformToFrontView() | ||
| 155 | } | 164 | } |
| 156 | return backView | 165 | return backView |
| 157 | }() | 166 | }() |
| @@ -160,17 +169,18 @@ class CNMainView : UIView{ | @@ -160,17 +169,18 @@ class CNMainView : UIView{ | ||
| 160 | { | 169 | { |
| 161 | self.addSubview(self.frontView) | 170 | self.addSubview(self.frontView) |
| 162 | self.addSubview(self.backView) | 171 | self.addSubview(self.backView) |
| 172 | + | ||
| 163 | self.backView.isHidden = true; | 173 | self.backView.isHidden = true; |
| 164 | 174 | ||
| 165 | - self.layer.cornerRadius = 20; | ||
| 166 | - self.layer.shadowOpacity = 1; | ||
| 167 | - self.layer.shadowColor = UIColor("#eeeeee")?.cgColor | ||
| 168 | - self.layer.shadowOffset = CGSize(width: 10, height: 10) | ||
| 169 | - self.layer.shadowRadius = 10; | 175 | +// self.layer.cornerRadius = 20; |
| 176 | +// self.layer.shadowOpacity = 1; | ||
| 177 | +// self.layer.shadowColor = UIColor("#eeeeee")?.cgColor | ||
| 178 | +// self.layer.shadowOffset = CGSize(width: 10, height: 10) | ||
| 179 | +// self.layer.shadowRadius = 10; | ||
| 170 | 180 | ||
| 171 | } | 181 | } |
| 172 | 182 | ||
| 173 | - /***********事件*****************/ | 183 | + // MARK: - 事件 |
| 174 | ///旋转到反面 | 184 | ///旋转到反面 |
| 175 | func transformToBacnkView() | 185 | func transformToBacnkView() |
| 176 | { | 186 | { |
metaCode/Classes/Other/ViewController.swift renamed to metaCode/Classes/Main/Mine/Controller/CNMineViewController.swift
| 1 | // | 1 | // |
| 2 | -// ViewController.swift | 2 | +// CNMineViewController.swift |
| 3 | // metaCode | 3 | // metaCode |
| 4 | // | 4 | // |
| 5 | // Created by iOS on 2023/5/30. | 5 | // Created by iOS on 2023/5/30. |
| @@ -8,13 +8,13 @@ | @@ -8,13 +8,13 @@ | ||
| 8 | import UIKit | 8 | import UIKit |
| 9 | import CNLiveRequestBastKit | 9 | import CNLiveRequestBastKit |
| 10 | 10 | ||
| 11 | -class ViewController: UIViewController { | 11 | +class CNMineViewController: CNLiveBaseViewController { |
| 12 | 12 | ||
| 13 | override func viewDidLoad() { | 13 | override func viewDidLoad() { |
| 14 | super.viewDidLoad() | 14 | super.viewDidLoad() |
| 15 | // Do any additional setup after loading the view. | 15 | // Do any additional setup after loading the view. |
| 16 | 16 | ||
| 17 | - self.view.backgroundColor = .gray | 17 | + self.view.backgroundColor = KVCBackgroupColor |
| 18 | 18 | ||
| 19 | 19 | ||
| 20 | let button = UIButton() | 20 | let button = UIButton() |
metaCode/Classes/Other/AppDelegate.swift
| @@ -18,8 +18,8 @@ class AppDelegate: UIResponder, UIApplicationDelegate { | @@ -18,8 +18,8 @@ class AppDelegate: UIResponder, UIApplicationDelegate { | ||
| 18 | 18 | ||
| 19 | // Override point for customization after application launch. | 19 | // Override point for customization after application launch. |
| 20 | window = UIWindow.init(frame: UIScreen.main.bounds) | 20 | window = UIWindow.init(frame: UIScreen.main.bounds) |
| 21 | - window?.backgroundColor = UIColor.white | ||
| 22 | - window?.rootViewController = CNMetaCodeHomePageController.init() | 21 | + window?.backgroundColor = KVCBackgroupColor |
| 22 | + window?.rootViewController = CNLiveBaseTabBarViewController.init() | ||
| 23 | window?.makeKeyAndVisible() | 23 | window?.makeKeyAndVisible() |
| 24 | 24 | ||
| 25 | 25 |
metaCode/Supporting Files/Assets.xcassets/Home/Contents.json
0 → 100644
metaCode/Supporting Files/Assets.xcassets/collectMoneyImage.imageset/4661683514280_.pic.jpg renamed to metaCode/Supporting Files/Assets.xcassets/Home/collectMoneyImage.imageset/4661683514280_.pic.jpg
75 KB
metaCode/Supporting Files/Assets.xcassets/collectMoneyImage.imageset/Contents.json renamed to metaCode/Supporting Files/Assets.xcassets/Home/collectMoneyImage.imageset/Contents.json
metaCode/Supporting Files/Assets.xcassets/Home/homePage_backBtn_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_backBtn_icon.imageset/回到首页@2x.png
0 → 100644
1.73 KB
metaCode/Supporting Files/Assets.xcassets/Home/homePage_backBtn_icon.imageset/回到首页@3x.png
0 → 100644
2.99 KB
metaCode/Supporting Files/Assets.xcassets/homePage_backViewImage.imageset/4671683516653_.pic.jpg renamed to metaCode/Supporting Files/Assets.xcassets/Home/homePage_backViewImage.imageset/4671683516653_.pic.jpg
82.2 KB
metaCode/Supporting Files/Assets.xcassets/homePage_backViewImage.imageset/Contents.json renamed to metaCode/Supporting Files/Assets.xcassets/Home/homePage_backViewImage.imageset/Contents.json
metaCode/Supporting Files/Assets.xcassets/homePage_homePage_down.imageset/4491683252485_.pic.jpg renamed to metaCode/Supporting Files/Assets.xcassets/Home/homePage_homePage_down.imageset/4491683252485_.pic.jpg
5.25 KB
metaCode/Supporting Files/Assets.xcassets/homePage_homePage_down.imageset/Contents.json renamed to metaCode/Supporting Files/Assets.xcassets/Home/homePage_homePage_down.imageset/Contents.json
metaCode/Supporting Files/Assets.xcassets/homePage_mainView_front.imageset/4621683513846_.pic.jpg renamed to metaCode/Supporting Files/Assets.xcassets/Home/homePage_mainView_front.imageset/4621683513846_.pic.jpg
56.9 KB
metaCode/Supporting Files/Assets.xcassets/homePage_mainView_front.imageset/Contents.json renamed to metaCode/Supporting Files/Assets.xcassets/Home/homePage_mainView_front.imageset/Contents.json
metaCode/Supporting Files/Assets.xcassets/homePage_payMoneyImage.imageset/4651683514228_.pic.jpg renamed to metaCode/Supporting Files/Assets.xcassets/Home/homePage_payMoneyImage.imageset/4651683514228_.pic.jpg
52.1 KB
metaCode/Supporting Files/Assets.xcassets/homePage_payMoneyImage.imageset/Contents.json renamed to metaCode/Supporting Files/Assets.xcassets/Home/homePage_payMoneyImage.imageset/Contents.json
metaCode/Supporting Files/Assets.xcassets/homePage_topImage.imageset/4771683609542_.pic.jpg renamed to metaCode/Supporting Files/Assets.xcassets/Home/homePage_topImage.imageset/4771683609542_.pic.jpg
230 KB
metaCode/Supporting Files/Assets.xcassets/homePage_topImage.imageset/Contents.json renamed to metaCode/Supporting Files/Assets.xcassets/Home/homePage_topImage.imageset/Contents.json
metaCode/Supporting Files/Assets.xcassets/homePage_zhongguorenming_bank.imageset/4431683250159_.pic.jpg renamed to metaCode/Supporting Files/Assets.xcassets/Home/homePage_zhongguorenming_bank.imageset/4431683250159_.pic.jpg
79.4 KB
metaCode/Supporting Files/Assets.xcassets/homePage_zhongguorenming_bank.imageset/Contents.json renamed to metaCode/Supporting Files/Assets.xcassets/Home/homePage_zhongguorenming_bank.imageset/Contents.json
metaCode/Supporting Files/Assets.xcassets/TabBar/Contents.json
0 → 100644
metaCode/Supporting Files/Assets.xcassets/TabBar/tabbar_backgroup.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/TabBar/tabbar_backgroup.imageset/背景图@2x.png
0 → 100644
2.68 KB
metaCode/Supporting Files/Assets.xcassets/TabBar/tabbar_backgroup.imageset/背景图@3x.png
0 → 100644
5.25 KB
metaCode/Supporting Files/Assets.xcassets/TabBar/tabbar_hoem_icon_default.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/TabBar/tabbar_hoem_icon_default.imageset/首页-未选中@2x.png
0 → 100644
1.26 KB
metaCode/Supporting Files/Assets.xcassets/TabBar/tabbar_hoem_icon_default.imageset/首页-未选中@3x.png
0 → 100644
2.24 KB
metaCode/Supporting Files/Assets.xcassets/TabBar/tabbar_hoem_icon_selected.imageset/Contents.json
0 → 100644
| 1 | +{ | ||
| 2 | + "images" : [ | ||
| 3 | + { | ||
| 4 | + "idiom" : "universal", | ||
| 5 | + "scale" : "1x" | ||
| 6 | + }, | ||
| 7 | + { | ||
| 8 | + "filename" : "tabbar_hoem_icon_selected@2x.png", | ||
| 9 | + "idiom" : "universal", | ||
| 10 | + "scale" : "2x" | ||
| 11 | + }, | ||
| 12 | + { | ||
| 13 | + "filename" : "tabbar_hoem_icon_selected@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/TabBar/tabbar_hoem_icon_selected.imageset/tabbar_hoem_icon_selected@2x.png
0 → 100644
1.22 KB
metaCode/Supporting Files/Assets.xcassets/TabBar/tabbar_hoem_icon_selected.imageset/tabbar_hoem_icon_selected@3x.png
0 → 100644
2.25 KB
metaCode/Supporting Files/Assets.xcassets/TabBar/tabbar_mine_icon_default.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/TabBar/tabbar_mine_icon_default.imageset/我的-未选中@2x.png
0 → 100644
1.1 KB
metaCode/Supporting Files/Assets.xcassets/TabBar/tabbar_mine_icon_default.imageset/我的-未选中@3x.png
0 → 100644
2.03 KB
metaCode/Supporting Files/Assets.xcassets/TabBar/tabbar_mine_icon_selected.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/TabBar/tabbar_mine_icon_selected.imageset/我的@2x.png
0 → 100644
1.05 KB
metaCode/Supporting Files/Assets.xcassets/TabBar/tabbar_mine_icon_selected.imageset/我的@3x.png
0 → 100644
2 KB