├── .gitignore
├── LICENSE
├── README.md
├── WRNavigationBar
├── WRCustomNavigationBar.swift
└── WRNavigationBar.swift
├── WRNavigationBar_swift
├── Podfile
├── Podfile.lock
├── Pods
│ ├── Kingfisher
│ │ ├── LICENSE
│ │ ├── README.md
│ │ └── Sources
│ │ │ ├── AnimatedImageView.swift
│ │ │ ├── Box.swift
│ │ │ ├── CacheSerializer.swift
│ │ │ ├── Filter.swift
│ │ │ ├── FormatIndicatedCacheSerializer.swift
│ │ │ ├── Image.swift
│ │ │ ├── ImageCache.swift
│ │ │ ├── ImageDownloader.swift
│ │ │ ├── ImagePrefetcher.swift
│ │ │ ├── ImageProcessor.swift
│ │ │ ├── ImageTransition.swift
│ │ │ ├── ImageView+Kingfisher.swift
│ │ │ ├── Indicator.swift
│ │ │ ├── Kingfisher.h
│ │ │ ├── Kingfisher.swift
│ │ │ ├── KingfisherManager.swift
│ │ │ ├── KingfisherOptionsInfo.swift
│ │ │ ├── Placeholder.swift
│ │ │ ├── RequestModifier.swift
│ │ │ ├── Resource.swift
│ │ │ ├── String+MD5.swift
│ │ │ ├── ThreadHelper.swift
│ │ │ └── UIButton+Kingfisher.swift
│ ├── Manifest.lock
│ ├── Pods.xcodeproj
│ │ └── project.pbxproj
│ └── Target Support Files
│ │ ├── Kingfisher
│ │ ├── Info.plist
│ │ ├── Kingfisher-dummy.m
│ │ ├── Kingfisher-prefix.pch
│ │ ├── Kingfisher-umbrella.h
│ │ ├── Kingfisher.modulemap
│ │ └── Kingfisher.xcconfig
│ │ └── Pods-WRNavigationBar_swift
│ │ ├── Info.plist
│ │ ├── Pods-WRNavigationBar_swift-acknowledgements.markdown
│ │ ├── Pods-WRNavigationBar_swift-acknowledgements.plist
│ │ ├── Pods-WRNavigationBar_swift-dummy.m
│ │ ├── Pods-WRNavigationBar_swift-frameworks.sh
│ │ ├── Pods-WRNavigationBar_swift-resources.sh
│ │ ├── Pods-WRNavigationBar_swift-umbrella.h
│ │ ├── Pods-WRNavigationBar_swift.debug.xcconfig
│ │ ├── Pods-WRNavigationBar_swift.modulemap
│ │ └── Pods-WRNavigationBar_swift.release.xcconfig
├── WRNavigationBar_swift.xcodeproj
│ ├── project.pbxproj
│ └── project.xcworkspace
│ │ └── contents.xcworkspacedata
├── WRNavigationBar_swift.xcworkspace
│ └── contents.xcworkspacedata
├── WRNavigationBar_swift
│ ├── AppDelegate.swift
│ ├── Assets.xcassets
│ │ ├── AppIcon.appiconset
│ │ │ ├── 180wr.png
│ │ │ ├── Contents.json
│ │ │ └── wr120@2x.png
│ │ ├── Contents.json
│ │ ├── bottomImage.imageset
│ │ │ ├── 938A54DAB0905290EBBE392AE73286DC.jpg
│ │ │ └── Contents.json
│ │ ├── image1.imageset
│ │ │ ├── Contents.json
│ │ │ └── image1.jpg
│ │ ├── image2.imageset
│ │ │ ├── Contents.json
│ │ │ └── image2.jpg
│ │ ├── image3.imageset
│ │ │ ├── Contents.json
│ │ │ └── DF0999B79D020D160165A612636482E9.jpg
│ │ ├── image4.imageset
│ │ │ ├── Contents.json
│ │ │ └── 椭圆 2.png
│ │ ├── image5.imageset
│ │ │ ├── Contents.json
│ │ │ └── 我3.png
│ │ ├── image6.imageset
│ │ │ ├── B56C24FF94B6EB94E1DD1931343B37D3.jpg
│ │ │ └── Contents.json
│ │ ├── image7.imageset
│ │ │ ├── Contents.json
│ │ │ └── u=2864424897,2473674229&fm=26&gp=0.jpg
│ │ ├── image8.imageset
│ │ │ ├── Contents.json
│ │ │ └── cad334853a19ab63f278ed8532ff8ae1.jpeg
│ │ ├── imageNav.imageset
│ │ │ ├── Contents.json
│ │ │ └── u=1206318416,27195661&fm=26&gp=0.jpg
│ │ ├── localImg10.imageset
│ │ │ ├── Contents.json
│ │ │ └── localImg10.jpg
│ │ ├── localImg6.imageset
│ │ │ ├── 6.jpg
│ │ │ └── Contents.json
│ │ ├── localImg7.imageset
│ │ │ ├── Contents.json
│ │ │ └── localImg7.jpg
│ │ ├── localImg8.imageset
│ │ │ ├── Contents.json
│ │ │ └── localImg8.jpg
│ │ ├── localImg9.imageset
│ │ │ ├── Contents.json
│ │ │ └── localImg9.jpg
│ │ ├── millcolorGrad.imageset
│ │ │ ├── Contents.json
│ │ │ └── millcolorGrad.png
│ │ ├── mine.imageset
│ │ │ ├── Contents.json
│ │ │ ├── mine@2x.png
│ │ │ └── mine@3x.png
│ │ ├── mineHighlight.imageset
│ │ │ ├── Contents.json
│ │ │ ├── mineHighlight@2x.png
│ │ │ └── mineHighlight@3x.png
│ │ ├── mysl.imageset
│ │ │ ├── Contents.json
│ │ │ └── WechatIMG52.png
│ │ ├── test.imageset
│ │ │ ├── Contents.json
│ │ │ └── test.jpg
│ │ └── wbBg.imageset
│ │ │ ├── Contents.json
│ │ │ └── wbBG.png
│ ├── Base.lproj
│ │ ├── LaunchScreen.storyboard
│ │ └── Main.storyboard
│ ├── Demos
│ │ ├── AllTransparent.swift
│ │ ├── AntForestController.swift
│ │ ├── BaseNavigationController.swift
│ │ ├── BaseViewController.swift
│ │ ├── CustomListController.swift
│ │ ├── CustomNavBarController.swift
│ │ ├── ImageNavController.swift
│ │ ├── MillcolorGradController.swift
│ │ ├── MoveListController.swift
│ │ ├── NormalListController.swift
│ │ ├── QQAppController.swift
│ │ ├── QQMineController.swift
│ │ ├── QQZoneController.swift
│ │ ├── SecondViewController.swift
│ │ ├── SixthViewController.swift
│ │ ├── WeiBoMineController.swift
│ │ └── ZhiHuController.swift
│ ├── Info.plist
│ └── WRNavigationBar
│ │ ├── WRCustomNavigationBar.swift
│ │ ├── WRCycleScrollView
│ │ ├── WRCycleCell.swift
│ │ ├── WRCycleScrollView.swift
│ │ └── WRProxy.swift
│ │ └── WRNavigationBar.swift
└── WRNavigationBar_swiftTests
│ ├── Info.plist
│ └── WRNavigationBar_swiftTests.swift
└── screenshots
├── QQ我的资料页.gif
├── apps.png
├── mysl.gif
├── mysl滑动.gif
├── qq空间.gif
├── 处理右滑中断后.gif
├── 处理右滑返回手势后.gif
├── 导航栏显示图片.gif
├── 导航栏显示渐变色.gif
├── 拉钩App首页.gif
├── 效果图.png
├── 新浪微博个人中心.gif
├── 未处理右滑中断.gif
├── 未处理右滑返回手势.gif
├── 知乎日报.gif
├── 移动导航栏.gif
├── 自定义导航栏.gif
├── 蚂蚁森林.gif
└── 连续多个界面导航栏透明.gif
/.gitignore:
--------------------------------------------------------------------------------
1 | # Xcode
2 | #
3 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore
4 |
5 | ## Build generated
6 | build/
7 | DerivedData/
8 |
9 | ## Various settings
10 | *.pbxuser
11 | !default.pbxuser
12 | *.mode1v3
13 | !default.mode1v3
14 | *.mode2v3
15 | !default.mode2v3
16 | *.perspectivev3
17 | !default.perspectivev3
18 | xcuserdata/
19 |
20 | ## Other
21 | *.moved-aside
22 | *.xcuserstate
23 |
24 | ## Obj-C/Swift specific
25 | *.hmap
26 | *.ipa
27 | *.dSYM.zip
28 | *.dSYM
29 |
30 | ## Playgrounds
31 | timeline.xctimeline
32 | playground.xcworkspace
33 |
34 | # Swift Package Manager
35 | #
36 | # Add this line if you want to avoid checking in source code from Swift Package Manager dependencies.
37 | # Packages/
38 | .build/
39 |
40 | # CocoaPods
41 | #
42 | # We recommend against adding the Pods directory to your .gitignore. However
43 | # you should judge for yourself, the pros and cons are mentioned at:
44 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
45 | #
46 | # Pods/
47 |
48 | # Carthage
49 | #
50 | # Add this line if you want to avoid checking in source code from Carthage dependencies.
51 | # Carthage/Checkouts
52 |
53 | Carthage/Build
54 |
55 | # fastlane
56 | #
57 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
58 | # screenshots whenever they are needed.
59 | # For more information about the recommended setup visit:
60 | # https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Gitignore.md
61 |
62 | fastlane/report.xml
63 | fastlane/Preview.html
64 | fastlane/screenshots
65 | fastlane/test_output
66 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2017
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 | 
3 |
4 | [For Objective-C:https://github.com/wangrui460/WRNavigationBar](https://github.com/wangrui460/WRNavigationBar)
5 |
6 |
7 | ------------------------------------------------------------
8 | ## iOS 技术交流
9 | 我创建了一个 微信 iOS 技术交流群,欢迎小伙伴们加入一起交流学习~
10 |
11 | 可以加我微信我拉你进去(备注iOS),我的微信号 wr1204607318
12 |
13 | ## Requirements
14 | - iOS 8+
15 | - Xcode 8+
16 |
17 |
18 | ## Demo
19 |
20 | 
21 |
22 | 
23 |
24 | 
25 |
26 | 
27 |
28 | 
29 |
30 | 
31 |
32 | 
33 |
34 | 
35 |
36 | 
37 |
38 | 
39 |
40 |
41 | ## Installation
42 |
43 | > **手动拖入**
44 | > 将 WRNavigationBar 文件夹拽入项目中即可使用
45 |
46 | ## How To Use
47 |
48 | 具体使用方法请参考Demo
49 |
50 | // 一行代码搞定导航栏颜色
51 | navBarBarTintColor = .white
52 | // 一行代码搞定导航栏透明度
53 | navBarBackgroundAlpha = alpha
54 | // 一行代码搞定导航栏两边按钮颜色
55 | navBarTintColor = UIColor(red: 0, green: 0.478431, blue: 1, alpha: 1.0)
56 | // 一行代码搞定导航栏上标题颜色
57 | navBarTitleColor = .black
58 | // 一行代码搞定状态栏是 default 还是 lightContent
59 | statusBarStyle = .default
60 | // 一行代码搞定导航栏底部分割线是否隐藏
61 | navBarShadowImageHidden = true;
62 |
63 |
64 |
65 | // 设置导航栏默认的背景颜色
66 | UIColor.defaultNavBarBarTintColor = UIColor.init(red: 0/255.0, green: 175/255.0, blue: 240/255.0, alpha: 1)
67 | // 设置导航栏所有按钮的默认颜色
68 | UIColor.defaultNavBarTintColor = .white
69 | // 设置导航栏标题默认颜色
70 | UIColor.defaultNavBarTitleColor = .white
71 | // 统一设置状态栏样式
72 | UIColor.defaultStatusBarStyle = .lightContent
73 | // 如果需要设置导航栏底部分割线隐藏,可以在这里统一设置
74 | UIColor.defaultShadowImageHidden = true
75 |
76 |
77 |
78 | ## See detail
79 | 我的简书: [韦德460](http://www.jianshu.com/p/7e92451ab0b2)
80 |
81 |
82 | ## Update
83 | - **2017.12.09**
84 | 解决问题:解决导航栏颜色和标题颜色改变失败的bug
85 |
86 | - **2017.12.09**
87 | 解决问题:解决点击返回按钮导航栏标题颜色闪烁的问题
88 |
89 | - **2017.11.29**-
90 | 更新:解决部分用户设置导航栏无效的问题~
91 |
92 | - **2017.11.29**-
93 | 更新:支持自定义导航栏~
94 |
95 | - **2017.11.25**
96 | 更新:更新到 Swift 4,适配iOS 11、iPhone X,自定义导航栏再等两天~
97 |
98 | - **2017.07.22**
99 | 添加新DEMO:连续多个界面导航栏透明
100 |
101 | - **2017.07.09**
102 | 解决问题:当一个控制器中包含多个控制器时,导航栏颜色或透明度不正常的问题
103 |
104 | - **2017.07.04**
105 | 添加新功能:全局设置导航栏显示图片(不建议在非自定义导航栏中使用)
106 |
107 | - **2017.07.01**
108 | 添加新功能:导航栏可显示图片
109 |
110 | - **2017.06.29**
111 | 添加新功能:可单独设置每个控制器对应导航栏底部分割线是否隐藏
112 |
113 | - **2017.06.29**
114 | 解决问题:解决引入WRNavigationBar后,无法设置导航栏标题大小的问题
115 |
116 | - **2017.06.19**
117 | 解决问题:解决移动导航栏后右滑返回中途取消导致的导航栏错位的问题
118 |
119 | - **2017.06.15**
120 | 解决问题:解决scrollView正在滑动的时候,点击返回按钮,导航栏颜色变化突兀的问题
121 |
122 | - **2017.05.21**
123 | 解决问题:解决push导航栏没有渐变动画太突兀的问题
124 |
125 | - **2017.05.20**
126 | 解决问题:解决侧滑返回导航栏没有渐变动画太突兀的**问题
127 |
128 | - **2017.05.16**
129 | 新增Demo:完成自定义导航栏实现透明渐变等效果
130 |
131 | - **2017.05.12**
132 | 解决问题:侧滑一点松开透明的导航栏会变不透明
133 |
134 |
135 | ## License
136 |
137 | WRNavigationBar is available under the MIT license. See the LICENSE file for more info.
138 |
139 |
--------------------------------------------------------------------------------
/WRNavigationBar/WRCustomNavigationBar.swift:
--------------------------------------------------------------------------------
1 | //
2 | // WRCustomNavigationBar.swift
3 | // WRNavigationBar_swift
4 | //
5 | // Created by itwangrui on 2017/11/25.
6 | // Copyright © 2017年 wangrui. All rights reserved.
7 | //
8 |
9 | import UIKit
10 |
11 | fileprivate let WRDefaultTitleSize:CGFloat = 18
12 | fileprivate let WRDefaultTitleColor = UIColor.black
13 | fileprivate let WRDefaultBackgroundColor = UIColor.white
14 | fileprivate let WRScreenWidth = UIScreen.main.bounds.size.width
15 |
16 |
17 | // MARK: - Router
18 | extension UIViewController
19 | {
20 | // A页面 弹出 登录页面B
21 | // presentedViewController: A页面
22 | // presentingViewController: B页面
23 |
24 | func wr_toLastViewController(animated:Bool)
25 | {
26 | if self.navigationController != nil
27 | {
28 | if self.navigationController?.viewControllers.count == 1
29 | {
30 | self.dismiss(animated: animated, completion: nil)
31 | } else {
32 | self.navigationController?.popViewController(animated: animated)
33 | }
34 | }
35 | else if self.presentingViewController != nil {
36 | self.dismiss(animated: animated, completion: nil)
37 | }
38 | }
39 |
40 | class func wr_currentViewController() -> UIViewController
41 | {
42 | if let rootVC = UIApplication.shared.delegate?.window??.rootViewController {
43 | return self.wr_currentViewController(from: rootVC)
44 | } else {
45 | return UIViewController()
46 | }
47 | }
48 |
49 | class func wr_currentViewController(from fromVC:UIViewController) -> UIViewController
50 | {
51 | if fromVC.isKind(of: UINavigationController.self) {
52 | let navigationController = fromVC as! UINavigationController
53 | return wr_currentViewController(from: navigationController.viewControllers.last!)
54 | }
55 | else if fromVC.isKind(of: UITabBarController.self) {
56 | let tabBarController = fromVC as! UITabBarController
57 | return wr_currentViewController(from: tabBarController.selectedViewController!)
58 | }
59 | else if fromVC.presentedViewController != nil {
60 | return wr_currentViewController(from:fromVC.presentingViewController!)
61 | }
62 | else {
63 | return fromVC
64 | }
65 | }
66 | }
67 |
68 |
69 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////
70 | class WRCustomNavigationBar: UIView
71 | {
72 | var onClickLeftButton:(()->())?
73 | var onClickRightButton:(()->())?
74 | var title:String? {
75 | willSet {
76 | titleLabel.isHidden = false
77 | titleLabel.text = newValue
78 | }
79 | }
80 | var titleLabelColor:UIColor? {
81 | willSet {
82 | titleLabel.textColor = newValue
83 | }
84 | }
85 | var titleLabelFont:UIFont? {
86 | willSet {
87 | titleLabel.font = newValue
88 | }
89 | }
90 | var barBackgroundColor:UIColor? {
91 | willSet {
92 | backgroundImageView.isHidden = true
93 | backgroundView.isHidden = false
94 | backgroundView.backgroundColor = newValue
95 | }
96 | }
97 | var barBackgroundImage:UIImage? {
98 | willSet {
99 | backgroundView.isHidden = true
100 | backgroundImageView.isHidden = false
101 | backgroundImageView.image = newValue
102 | }
103 | }
104 |
105 | // fileprivate UI variable
106 | fileprivate lazy var titleLabel:UILabel = {
107 | let label = UILabel()
108 | label.textColor = WRDefaultTitleColor
109 | label.font = UIFont.systemFont(ofSize: WRDefaultTitleSize)
110 | label.textAlignment = .center
111 | label.isHidden = true
112 | return label
113 | }()
114 |
115 | fileprivate lazy var leftButton:UIButton = {
116 | let button = UIButton()
117 | button.imageView?.contentMode = .center
118 | button.isHidden = true
119 | button.addTarget(self, action: #selector(clickBack), for: .touchUpInside)
120 | return button
121 | }()
122 |
123 | fileprivate lazy var rightButton:UIButton = {
124 | let button = UIButton()
125 | button.imageView?.contentMode = .center
126 | button.isHidden = true
127 | button.addTarget(self, action: #selector(clickRight), for: .touchUpInside)
128 | return button
129 | }()
130 |
131 | fileprivate lazy var bottomLine:UIView = {
132 | let view = UIView()
133 | view.backgroundColor = UIColor(red: (218.0/255.0), green: (218.0/255.0), blue: (218.0/255.0), alpha: 1.0)
134 | return view
135 | }()
136 |
137 | fileprivate lazy var backgroundView:UIView = {
138 | let view = UIView()
139 | return view
140 | }()
141 |
142 | fileprivate lazy var backgroundImageView:UIImageView = {
143 | let imgView = UIImageView()
144 | imgView.isHidden = true
145 | return imgView
146 | }()
147 |
148 | // fileprivate other variable
149 | fileprivate static var isIphoneX:Bool {
150 | get {
151 | return UIScreen.main.bounds.equalTo(CGRect(x: 0, y: 0, width: 375, height: 812))
152 | }
153 | }
154 | fileprivate static var navBarBottom:Int {
155 | get {
156 | return isIphoneX ? 88 : 64
157 | }
158 | }
159 |
160 | // init
161 | class func CustomNavigationBar() -> WRCustomNavigationBar {
162 | let frame = CGRect(x: 0, y: 0, width: WRScreenWidth, height: CGFloat(navBarBottom))
163 | return WRCustomNavigationBar(frame: frame)
164 | }
165 | override init(frame: CGRect) {
166 | super.init(frame: frame)
167 | setupView()
168 | }
169 | required init?(coder aDecoder: NSCoder) {
170 | super.init(coder: aDecoder)
171 | setupView()
172 | }
173 |
174 | func setupView()
175 | {
176 | addSubview(backgroundView)
177 | addSubview(backgroundImageView)
178 | addSubview(leftButton)
179 | addSubview(titleLabel)
180 | addSubview(rightButton)
181 | addSubview(bottomLine)
182 | updateFrame()
183 | backgroundColor = UIColor.clear
184 | backgroundView.backgroundColor = WRDefaultBackgroundColor
185 | }
186 | func updateFrame()
187 | {
188 | let top:CGFloat = WRCustomNavigationBar.isIphoneX ? 44 : 20
189 | let margin:CGFloat = 0
190 | let buttonHeight:CGFloat = 44
191 | let buttonWidth:CGFloat = 44
192 | let titleLabelHeight:CGFloat = 44
193 | let titleLabelWidth:CGFloat = 180
194 |
195 | backgroundView.frame = self.bounds
196 | backgroundImageView.frame = self.bounds
197 | leftButton.frame = CGRect(x: margin, y: top, width: buttonWidth, height: buttonHeight)
198 | rightButton.frame = CGRect(x: WRScreenWidth-buttonWidth-margin, y: top, width: buttonWidth, height: buttonHeight)
199 | titleLabel.frame = CGRect(x: (WRScreenWidth-titleLabelWidth)/2.0, y: top, width: titleLabelWidth, height: titleLabelHeight)
200 | bottomLine.frame = CGRect(x: 0, y: bounds.height-0.5, width: WRScreenWidth, height: 0.5)
201 | }
202 | }
203 |
204 |
205 | extension WRCustomNavigationBar
206 | {
207 | func wr_setBottomLineHidden(hidden:Bool) {
208 | bottomLine.isHidden = hidden
209 | }
210 | func wr_setBackgroundAlpha(alpha:CGFloat) {
211 | backgroundView.alpha = alpha
212 | backgroundImageView.alpha = alpha
213 | bottomLine.alpha = alpha
214 | }
215 | func wr_setTintColor(color:UIColor) {
216 | leftButton.setTitleColor(color, for: .normal)
217 | rightButton.setTitleColor(color, for: .normal)
218 | titleLabel.textColor = color
219 | }
220 |
221 | // 左右按钮共有方法
222 | func wr_setLeftButton(normal:UIImage, highlighted:UIImage) {
223 | wr_setLeftButton(normal: normal, highlighted: highlighted, title: nil, titleColor: nil)
224 | }
225 | func wr_setLeftButton(image:UIImage) {
226 | wr_setLeftButton(normal: image, highlighted: image, title: nil, titleColor: nil)
227 | }
228 | func wr_setLeftButton(title:String, titleColor:UIColor) {
229 | wr_setLeftButton(normal: nil, highlighted: nil, title: title, titleColor: titleColor)
230 | }
231 |
232 | func wr_setRightButton(normal:UIImage, highlighted:UIImage) {
233 | wr_setRightButton(normal: normal, highlighted: highlighted, title: nil, titleColor: nil)
234 | }
235 | func wr_setRightButton(image:UIImage) {
236 | wr_setRightButton(normal: image, highlighted: image, title: nil, titleColor: nil)
237 | }
238 | func wr_setRightButton(title:String, titleColor:UIColor) {
239 | wr_setRightButton(normal: nil, highlighted: nil, title: title, titleColor: titleColor)
240 | }
241 |
242 |
243 | // 左右按钮私有方法
244 | private func wr_setLeftButton(normal:UIImage?, highlighted:UIImage?, title:String?, titleColor:UIColor?) {
245 | leftButton.isHidden = false
246 | leftButton.setImage(normal, for: .normal)
247 | leftButton.setImage(highlighted, for: .highlighted)
248 | leftButton.setTitle(title, for: .normal)
249 | leftButton.setTitleColor(titleColor, for: .normal)
250 | }
251 | private func wr_setRightButton(normal:UIImage?, highlighted:UIImage?, title:String?, titleColor:UIColor?) {
252 | rightButton.isHidden = false
253 | rightButton.setImage(normal, for: .normal)
254 | rightButton.setImage(highlighted, for: .highlighted)
255 | rightButton.setTitle(title, for: .normal)
256 | rightButton.setTitleColor(titleColor, for: .normal)
257 | }
258 | }
259 |
260 |
261 | // MARK: - 导航栏左右按钮事件
262 | extension WRCustomNavigationBar
263 | {
264 | @objc func clickBack() {
265 | if let onClickBack = onClickLeftButton {
266 | onClickBack()
267 | } else {
268 | let currentVC = UIViewController.wr_currentViewController()
269 | currentVC.wr_toLastViewController(animated: true)
270 | }
271 | }
272 | @objc func clickRight() {
273 | if let onClickRight = onClickRightButton {
274 | onClickRight()
275 | }
276 | }
277 | }
278 |
279 |
280 |
281 |
282 |
283 |
284 |
285 |
286 |
287 |
288 |
289 |
290 |
291 |
292 |
293 |
294 |
295 |
296 |
297 |
298 |
299 |
300 |
301 |
302 |
--------------------------------------------------------------------------------
/WRNavigationBar_swift/Podfile:
--------------------------------------------------------------------------------
1 |
2 |
3 | # 修改过得第三方库
4 |
5 |
6 | platform :ios, '8.0'
7 | use_frameworks!
8 |
9 | target ‘WRNavigationBar_swift’ do
10 |
11 | #swift
12 | pod 'Kingfisher'
13 |
14 | end
15 |
--------------------------------------------------------------------------------
/WRNavigationBar_swift/Podfile.lock:
--------------------------------------------------------------------------------
1 | PODS:
2 | - Kingfisher (4.3.1)
3 |
4 | DEPENDENCIES:
5 | - Kingfisher
6 |
7 | SPEC CHECKSUMS:
8 | Kingfisher: 75541c4b62f02e1fde6f9772303de3d9ebe8f5b3
9 |
10 | PODFILE CHECKSUM: eedd5593b4e862f4a6b0ebf6fd6f3f022a9f6b1d
11 |
12 | COCOAPODS: 1.3.1
13 |
--------------------------------------------------------------------------------
/WRNavigationBar_swift/Pods/Kingfisher/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2017 Wei Wang
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
23 |
--------------------------------------------------------------------------------
/WRNavigationBar_swift/Pods/Kingfisher/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 | Kingfisher is a lightweight, pure-Swift library for downloading and caching images from the web. This project is heavily inspired by the popular [SDWebImage](https://github.com/rs/SDWebImage). It provides you a chance to use a pure-Swift alternative in your next app.
19 |
20 | ## Features
21 |
22 | - [x] Asynchronous image downloading and caching.
23 | - [x] `URLSession`-based networking. Basic image processors and filters supplied.
24 | - [x] Multiple-layer cache for both memory and disk.
25 | - [x] Cancelable downloading and processing tasks to improve performance.
26 | - [x] Independent components. Use the downloader or caching system separately as you need.
27 | - [x] Prefetching images and showing them from cache later when necessary.
28 | - [x] Extensions for `UIImageView`, `NSImage` and `UIButton` to directly set an image from a URL.
29 | - [x] Built-in transition animation when setting images.
30 | - [x] Customizable placeholder while loading images.
31 | - [x] Extensible image processing and image format support.
32 |
33 | The simplest use-case is setting an image to an image view with the `UIImageView` extension:
34 |
35 | ```swift
36 | let url = URL(string: "url_of_your_image")
37 | imageView.kf.setImage(with: url)
38 | ```
39 |
40 | Kingfisher will download the image from `url`, send it to both the memory cache and the disk cache, and display it in `imageView`. When you use the same code later, the image will be retrieved from cache and shown immediately.
41 |
42 | ## Requirements
43 |
44 | - iOS 8.0+ / macOS 10.10+ / tvOS 9.0+ / watchOS 2.0+
45 | - Swift 4 (Kingfisher 4.x), Swift 3 (Kingfisher 3.x)
46 |
47 | Main development of Kingfisher is based on Swift 4. Only critical bug fixes will be applied to Kingfisher 3.x.
48 |
49 | - Kingfisher 4.0 Migration - Kingfisher 3.x should be source compatible to Kingfisher 4. The reason for a major update is that we need to specify the Swift version explicitly for Xcode. All deprecated methods in Kingfisher 3 has been removed, so please ensure you have no warning left before you migrate from Kingfisher 3 to Kingfisher 4. If you have any trouble in migrating, please open an issue to discuss.
50 | - [Kingfisher 3.0 Migration Guide](https://github.com/onevcat/Kingfisher/wiki/Kingfisher-3.0-Migration-Guide) - If you are upgrading to Kingfisher 3.x from an earlier version, please read this for more information.
51 |
52 | ## Next Steps
53 |
54 | We prepared a [wiki page](https://github.com/onevcat/Kingfisher/wiki). You can find tons of useful things there.
55 |
56 | * [Installation Guide](https://github.com/onevcat/Kingfisher/wiki/Installation-Guide) - Follow it to integrate Kingfisher into your project.
57 | * [Cheat Sheet](https://github.com/onevcat/Kingfisher/wiki/Cheat-Sheet)- Curious about what Kingfisher could do and how would it look like when used in your project? See this page for useful code snippets. If you are already familiar with Kingfisher, you could also learn new tricks to improve the way you use Kingfisher!
58 | * [API Reference](http://onevcat.github.io/Kingfisher/) - Lastly, please remember to read the full whenever you may need a more detailed reference.
59 |
60 | ## Other
61 |
62 | ### Future of Kingfisher
63 |
64 | I want to keep Kingfisher lightweight. This framework will focus on providing a simple solution for downloading and caching images. This doesn’t mean the framework can’t be improved. Kingfisher is far from perfect, so necessary and useful updates will be made to make it better.
65 |
66 | ### Developments and Tests
67 |
68 | Any contributing and pull requests are warmly welcome. However, before you plan to implement some features or try to fix an uncertain issue, it is recommended to open a discussion first.
69 |
70 | The test images are contained in another project to keep this project repo fast and slim. You could run `./setup.sh` in the root folder of Kingfisher to clone the test images when you need to run the tests target. It would be appreciated if your pull requests could build and with all tests green. :)
71 |
72 | ### About the logo
73 |
74 | The logo of Kingfisher is inspired by [Tangram (七巧板)](http://en.wikipedia.org/wiki/Tangram), a dissection puzzle consisting of seven flat shapes from China. I believe she's a kingfisher bird instead of a swift, but someone insists that she is a pigeon. I guess I should give her a name. Hi, guys, do you have any suggestions?
75 |
76 | ### Contact
77 |
78 | Follow and contact me on [Twitter](http://twitter.com/onevcat) or [Sina Weibo](http://weibo.com/onevcat). If you find an issue, just [open a ticket](https://github.com/onevcat/Kingfisher/issues/new). Pull requests are warmly welcome as well.
79 |
80 | ## Contributors
81 |
82 | This project exists thanks to all the people who contribute. [[Contribute]](https://github.com/onevcat/Kingfisher/blob/master/CONTRIBUTING.md).
83 |
84 |
85 |
86 | ## Backers
87 |
88 | Thank you to all our backers! 🙏 [[Become a backer](https://opencollective.com/Kingfisher#backer)]
89 |
90 |
91 |
92 |
93 | ## Sponsors
94 |
95 | Support this project by becoming a sponsor. Your logo will show up here with a link to your website. [[Become a sponsor](https://opencollective.com/Kingfisher#sponsor)]
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 | ### License
111 |
112 | Kingfisher is released under the MIT license. See LICENSE for details.
113 |
114 |
115 |
--------------------------------------------------------------------------------
/WRNavigationBar_swift/Pods/Kingfisher/Sources/Box.swift:
--------------------------------------------------------------------------------
1 | //
2 | // Box.swift
3 | // Kingfisher
4 | //
5 | // Created by WANG WEI on 2016/09/12.
6 | // Copyright © 2016年 Wei Wang. All rights reserved.
7 | //
8 |
9 | import Foundation
10 |
11 | class Box {
12 | let value: T
13 | init(value: T) {
14 | self.value = value
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/WRNavigationBar_swift/Pods/Kingfisher/Sources/CacheSerializer.swift:
--------------------------------------------------------------------------------
1 | //
2 | // CacheSerializer.swift
3 | // Kingfisher
4 | //
5 | // Created by Wei Wang on 2016/09/02.
6 | //
7 | // Copyright (c) 2017 Wei Wang
8 | //
9 | // Permission is hereby granted, free of charge, to any person obtaining a copy
10 | // of this software and associated documentation files (the "Software"), to deal
11 | // in the Software without restriction, including without limitation the rights
12 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | // copies of the Software, and to permit persons to whom the Software is
14 | // furnished to do so, subject to the following conditions:
15 | //
16 | // The above copyright notice and this permission notice shall be included in
17 | // all copies or substantial portions of the Software.
18 | //
19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 | // THE SOFTWARE.
26 |
27 | import Foundation
28 |
29 | /// An `CacheSerializer` would be used to convert some data to an image object for
30 | /// retrieving from disk cache and vice versa for storing to disk cache.
31 | public protocol CacheSerializer {
32 |
33 | /// Get the serialized data from a provided image
34 | /// and optional original data for caching to disk.
35 | ///
36 | ///
37 | /// - parameter image: The image needed to be serialized.
38 | /// - parameter original: The original data which is just downloaded.
39 | /// If the image is retrieved from cache instead of
40 | /// downloaded, it will be `nil`.
41 | ///
42 | /// - returns: A data which will be stored to cache, or `nil` when no valid
43 | /// data could be serialized.
44 | func data(with image: Image, original: Data?) -> Data?
45 |
46 | /// Get an image deserialized from provided data.
47 | ///
48 | /// - parameter data: The data from which an image should be deserialized.
49 | /// - parameter options: Options for deserialization.
50 | ///
51 | /// - returns: An image deserialized or `nil` when no valid image
52 | /// could be deserialized.
53 | func image(with data: Data, options: KingfisherOptionsInfo?) -> Image?
54 | }
55 |
56 |
57 | /// `DefaultCacheSerializer` is a basic `CacheSerializer` used in default cache of
58 | /// Kingfisher. It could serialize and deserialize PNG, JEPG and GIF images. For
59 | /// image other than these formats, a normalized `pngRepresentation` will be used.
60 | public struct DefaultCacheSerializer: CacheSerializer {
61 |
62 | public static let `default` = DefaultCacheSerializer()
63 | private init() {}
64 |
65 | public func data(with image: Image, original: Data?) -> Data? {
66 | let imageFormat = original?.kf.imageFormat ?? .unknown
67 |
68 | let data: Data?
69 | switch imageFormat {
70 | case .PNG: data = image.kf.pngRepresentation()
71 | case .JPEG: data = image.kf.jpegRepresentation(compressionQuality: 1.0)
72 | case .GIF: data = image.kf.gifRepresentation()
73 | case .unknown: data = original ?? image.kf.normalized.kf.pngRepresentation()
74 | }
75 |
76 | return data
77 | }
78 |
79 | public func image(with data: Data, options: KingfisherOptionsInfo?) -> Image? {
80 | let options = options ?? KingfisherEmptyOptionsInfo
81 | return Kingfisher.image(
82 | data: data,
83 | scale: options.scaleFactor,
84 | preloadAllAnimationData: options.preloadAllAnimationData,
85 | onlyFirstFrame: options.onlyLoadFirstFrame)
86 | }
87 | }
88 |
--------------------------------------------------------------------------------
/WRNavigationBar_swift/Pods/Kingfisher/Sources/Filter.swift:
--------------------------------------------------------------------------------
1 | //
2 | // Filter.swift
3 | // Kingfisher
4 | //
5 | // Created by Wei Wang on 2016/08/31.
6 | //
7 | // Copyright (c) 2017 Wei Wang
8 | //
9 | // Permission is hereby granted, free of charge, to any person obtaining a copy
10 | // of this software and associated documentation files (the "Software"), to deal
11 | // in the Software without restriction, including without limitation the rights
12 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | // copies of the Software, and to permit persons to whom the Software is
14 | // furnished to do so, subject to the following conditions:
15 | //
16 | // The above copyright notice and this permission notice shall be included in
17 | // all copies or substantial portions of the Software.
18 | //
19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 | // THE SOFTWARE.
26 |
27 |
28 |
29 | import CoreImage
30 | import Accelerate
31 |
32 | // Reuse the same CI Context for all CI drawing.
33 | private let ciContext = CIContext(options: nil)
34 |
35 | /// Transformer method which will be used in to provide a `Filter`.
36 | public typealias Transformer = (CIImage) -> CIImage?
37 |
38 | /// Supply a filter to create an `ImageProcessor`.
39 | public protocol CIImageProcessor: ImageProcessor {
40 | var filter: Filter { get }
41 | }
42 |
43 | extension CIImageProcessor {
44 | public func process(item: ImageProcessItem, options: KingfisherOptionsInfo) -> Image? {
45 | switch item {
46 | case .image(let image):
47 | return image.kf.apply(filter)
48 | case .data(_):
49 | return (DefaultImageProcessor.default >> self).process(item: item, options: options)
50 | }
51 | }
52 | }
53 |
54 | /// Wrapper for a `Transformer` of CIImage filters.
55 | public struct Filter {
56 |
57 | let transform: Transformer
58 |
59 | public init(tranform: @escaping Transformer) {
60 | self.transform = tranform
61 | }
62 |
63 | /// Tint filter which will apply a tint color to images.
64 | public static var tint: (Color) -> Filter = {
65 | color in
66 | Filter { input in
67 | let colorFilter = CIFilter(name: "CIConstantColorGenerator")!
68 | colorFilter.setValue(CIColor(color: color), forKey: kCIInputColorKey)
69 |
70 | let colorImage = colorFilter.outputImage
71 | let filter = CIFilter(name: "CISourceOverCompositing")!
72 | filter.setValue(colorImage, forKey: kCIInputImageKey)
73 | filter.setValue(input, forKey: kCIInputBackgroundImageKey)
74 | #if swift(>=4.0)
75 | return filter.outputImage?.cropped(to: input.extent)
76 | #else
77 | return filter.outputImage?.cropping(to: input.extent)
78 | #endif
79 | }
80 | }
81 |
82 | public typealias ColorElement = (CGFloat, CGFloat, CGFloat, CGFloat)
83 |
84 | /// Color control filter which will apply color control change to images.
85 | public static var colorControl: (ColorElement) -> Filter = { arg -> Filter in
86 | let (brightness, contrast, saturation, inputEV) = arg
87 | return Filter { input in
88 | let paramsColor = [kCIInputBrightnessKey: brightness,
89 | kCIInputContrastKey: contrast,
90 | kCIInputSaturationKey: saturation]
91 |
92 | let paramsExposure = [kCIInputEVKey: inputEV]
93 | #if swift(>=4.0)
94 | let blackAndWhite = input.applyingFilter("CIColorControls", parameters: paramsColor)
95 | return blackAndWhite.applyingFilter("CIExposureAdjust", parameters: paramsExposure)
96 | #else
97 | let blackAndWhite = input.applyingFilter("CIColorControls", withInputParameters: paramsColor)
98 | return blackAndWhite.applyingFilter("CIExposureAdjust", withInputParameters: paramsExposure)
99 | #endif
100 | }
101 |
102 | }
103 | }
104 |
105 | extension Kingfisher where Base: Image {
106 | /// Apply a `Filter` containing `CIImage` transformer to `self`.
107 | ///
108 | /// - parameter filter: The filter used to transform `self`.
109 | ///
110 | /// - returns: A transformed image by input `Filter`.
111 | ///
112 | /// - Note: Only CG-based images are supported. If any error happens during transforming, `self` will be returned.
113 | public func apply(_ filter: Filter) -> Image {
114 |
115 | guard let cgImage = cgImage else {
116 | assertionFailure("[Kingfisher] Tint image only works for CG-based image.")
117 | return base
118 | }
119 |
120 | let inputImage = CIImage(cgImage: cgImage)
121 | guard let outputImage = filter.transform(inputImage) else {
122 | return base
123 | }
124 |
125 | guard let result = ciContext.createCGImage(outputImage, from: outputImage.extent) else {
126 | assertionFailure("[Kingfisher] Can not make an tint image within context.")
127 | return base
128 | }
129 |
130 | #if os(macOS)
131 | return fixedForRetinaPixel(cgImage: result, to: size)
132 | #else
133 | return Image(cgImage: result, scale: base.scale, orientation: base.imageOrientation)
134 | #endif
135 | }
136 |
137 | }
138 |
--------------------------------------------------------------------------------
/WRNavigationBar_swift/Pods/Kingfisher/Sources/FormatIndicatedCacheSerializer.swift:
--------------------------------------------------------------------------------
1 | //
2 | // RequestModifier.swift
3 | // Kingfisher
4 | //
5 | // Created by Junyu Kuang on 5/28/17.
6 | //
7 | // Copyright (c) 2017 Wei Wang
8 | //
9 | // Permission is hereby granted, free of charge, to any person obtaining a copy
10 | // of this software and associated documentation files (the "Software"), to deal
11 | // in the Software without restriction, including without limitation the rights
12 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | // copies of the Software, and to permit persons to whom the Software is
14 | // furnished to do so, subject to the following conditions:
15 | //
16 | // The above copyright notice and this permission notice shall be included in
17 | // all copies or substantial portions of the Software.
18 | //
19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 | // THE SOFTWARE.
26 |
27 | import Foundation
28 |
29 | /// `FormatIndicatedCacheSerializer` let you indicate an image format for serialized caches.
30 | ///
31 | /// It could serialize and deserialize PNG, JEPG and GIF images. For
32 | /// image other than these formats, a normalized `pngRepresentation` will be used.
33 | ///
34 | /// Example:
35 | /// ````
36 | /// private let profileImageSize = CGSize(width: 44, height: 44)
37 | ///
38 | /// private let imageProcessor = RoundCornerImageProcessor(
39 | /// cornerRadius: profileImageSize.width / 2, targetSize: profileImageSize)
40 | ///
41 | /// private let optionsInfo: KingfisherOptionsInfo = [
42 | /// .cacheSerializer(FormatIndicatedCacheSerializer.png),
43 | /// .backgroundDecode, .processor(imageProcessor), .scaleFactor(UIScreen.main.scale)]
44 | ///
45 | /// extension UIImageView {
46 | /// func setProfileImage(with url: URL) {
47 | /// // Image will always cached as PNG format to preserve alpha channel for round rect.
48 | /// _ = kf.setImage(with: url, options: optionsInfo)
49 | /// }
50 | ///}
51 | /// ````
52 | public struct FormatIndicatedCacheSerializer: CacheSerializer {
53 |
54 | public static let png = FormatIndicatedCacheSerializer(imageFormat: .PNG)
55 | public static let jpeg = FormatIndicatedCacheSerializer(imageFormat: .JPEG)
56 | public static let gif = FormatIndicatedCacheSerializer(imageFormat: .GIF)
57 |
58 | /// The indicated image format.
59 | private let imageFormat: ImageFormat
60 |
61 | public func data(with image: Image, original: Data?) -> Data? {
62 |
63 | func imageData(withFormat imageFormat: ImageFormat) -> Data? {
64 | switch imageFormat {
65 | case .PNG: return image.kf.pngRepresentation()
66 | case .JPEG: return image.kf.jpegRepresentation(compressionQuality: 1.0)
67 | case .GIF: return image.kf.gifRepresentation()
68 | case .unknown: return nil
69 | }
70 | }
71 |
72 | // generate data with indicated image format
73 | if let data = imageData(withFormat: imageFormat) {
74 | return data
75 | }
76 |
77 | let originalFormat = original?.kf.imageFormat ?? .unknown
78 |
79 | // generate data with original image's format
80 | if originalFormat != imageFormat, let data = imageData(withFormat: originalFormat) {
81 | return data
82 | }
83 |
84 | return original ?? image.kf.normalized.kf.pngRepresentation()
85 | }
86 |
87 | /// Same implementation as `DefaultCacheSerializer`.
88 | public func image(with data: Data, options: KingfisherOptionsInfo?) -> Image? {
89 | let options = options ?? KingfisherEmptyOptionsInfo
90 | return Kingfisher.image(
91 | data: data,
92 | scale: options.scaleFactor,
93 | preloadAllAnimationData: options.preloadAllAnimationData,
94 | onlyFirstFrame: options.onlyLoadFirstFrame)
95 | }
96 | }
97 |
--------------------------------------------------------------------------------
/WRNavigationBar_swift/Pods/Kingfisher/Sources/ImageTransition.swift:
--------------------------------------------------------------------------------
1 | //
2 | // ImageTransition.swift
3 | // Kingfisher
4 | //
5 | // Created by Wei Wang on 15/9/18.
6 | //
7 | // Copyright (c) 2017 Wei Wang
8 | //
9 | // Permission is hereby granted, free of charge, to any person obtaining a copy
10 | // of this software and associated documentation files (the "Software"), to deal
11 | // in the Software without restriction, including without limitation the rights
12 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | // copies of the Software, and to permit persons to whom the Software is
14 | // furnished to do so, subject to the following conditions:
15 | //
16 | // The above copyright notice and this permission notice shall be included in
17 | // all copies or substantial portions of the Software.
18 | //
19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 | // THE SOFTWARE.
26 |
27 | #if os(macOS)
28 | // Not implemented for macOS and watchOS yet.
29 |
30 | import AppKit
31 |
32 | /// Image transition is not supported on macOS.
33 | public enum ImageTransition {
34 | case none
35 | var duration: TimeInterval {
36 | return 0
37 | }
38 | }
39 |
40 | #elseif os(watchOS)
41 | import UIKit
42 | /// Image transition is not supported on watchOS.
43 | public enum ImageTransition {
44 | case none
45 | var duration: TimeInterval {
46 | return 0
47 | }
48 | }
49 | #else
50 | import UIKit
51 |
52 | /**
53 | Transition effect which will be used when an image downloaded and set by `UIImageView` extension API in Kingfisher.
54 | You can assign an enum value with transition duration as an item in `KingfisherOptionsInfo`
55 | to enable the animation transition.
56 |
57 | Apple's UIViewAnimationOptions is used under the hood.
58 | For custom transition, you should specified your own transition options, animations and
59 | comletion handler as well.
60 | */
61 | public enum ImageTransition {
62 | /// No animation transistion.
63 | case none
64 |
65 | /// Fade in the loaded image.
66 | case fade(TimeInterval)
67 |
68 | /// Flip from left transition.
69 | case flipFromLeft(TimeInterval)
70 |
71 | /// Flip from right transition.
72 | case flipFromRight(TimeInterval)
73 |
74 | /// Flip from top transition.
75 | case flipFromTop(TimeInterval)
76 |
77 | /// Flip from bottom transition.
78 | case flipFromBottom(TimeInterval)
79 |
80 | /// Custom transition.
81 | case custom(duration: TimeInterval,
82 | options: UIViewAnimationOptions,
83 | animations: ((UIImageView, UIImage) -> Void)?,
84 | completion: ((Bool) -> Void)?)
85 |
86 | var duration: TimeInterval {
87 | switch self {
88 | case .none: return 0
89 | case .fade(let duration): return duration
90 |
91 | case .flipFromLeft(let duration): return duration
92 | case .flipFromRight(let duration): return duration
93 | case .flipFromTop(let duration): return duration
94 | case .flipFromBottom(let duration): return duration
95 |
96 | case .custom(let duration, _, _, _): return duration
97 | }
98 | }
99 |
100 | var animationOptions: UIViewAnimationOptions {
101 | switch self {
102 | case .none: return []
103 | case .fade(_): return .transitionCrossDissolve
104 |
105 | case .flipFromLeft(_): return .transitionFlipFromLeft
106 | case .flipFromRight(_): return .transitionFlipFromRight
107 | case .flipFromTop(_): return .transitionFlipFromTop
108 | case .flipFromBottom(_): return .transitionFlipFromBottom
109 |
110 | case .custom(_, let options, _, _): return options
111 | }
112 | }
113 |
114 | var animations: ((UIImageView, UIImage) -> Void)? {
115 | switch self {
116 | case .custom(_, _, let animations, _): return animations
117 | default: return { $0.image = $1 }
118 | }
119 | }
120 |
121 | var completion: ((Bool) -> Void)? {
122 | switch self {
123 | case .custom(_, _, _, let completion): return completion
124 | default: return nil
125 | }
126 | }
127 | }
128 | #endif
129 |
--------------------------------------------------------------------------------
/WRNavigationBar_swift/Pods/Kingfisher/Sources/Indicator.swift:
--------------------------------------------------------------------------------
1 | //
2 | // Indicator.swift
3 | // Kingfisher
4 | //
5 | // Created by João D. Moreira on 30/08/16.
6 | //
7 | // Copyright (c) 2017 Wei Wang
8 | //
9 | // Permission is hereby granted, free of charge, to any person obtaining a copy
10 | // of this software and associated documentation files (the "Software"), to deal
11 | // in the Software without restriction, including without limitation the rights
12 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | // copies of the Software, and to permit persons to whom the Software is
14 | // furnished to do so, subject to the following conditions:
15 | //
16 | // The above copyright notice and this permission notice shall be included in
17 | // all copies or substantial portions of the Software.
18 | //
19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 | // THE SOFTWARE.
26 |
27 | #if os(macOS)
28 | import AppKit
29 | #else
30 | import UIKit
31 | #endif
32 |
33 | #if os(macOS)
34 | public typealias IndicatorView = NSView
35 | #else
36 | public typealias IndicatorView = UIView
37 | #endif
38 |
39 | public enum IndicatorType {
40 | /// No indicator.
41 | case none
42 | /// Use system activity indicator.
43 | case activity
44 | /// Use an image as indicator. GIF is supported.
45 | case image(imageData: Data)
46 | /// Use a custom indicator, which conforms to the `Indicator` protocol.
47 | case custom(indicator: Indicator)
48 | }
49 |
50 | // MARK: - Indicator Protocol
51 | public protocol Indicator {
52 | func startAnimatingView()
53 | func stopAnimatingView()
54 |
55 | var viewCenter: CGPoint { get set }
56 | var view: IndicatorView { get }
57 | }
58 |
59 | extension Indicator {
60 | #if os(macOS)
61 | public var viewCenter: CGPoint {
62 | get {
63 | let frame = view.frame
64 | return CGPoint(x: frame.origin.x + frame.size.width / 2.0, y: frame.origin.y + frame.size.height / 2.0 )
65 | }
66 | set {
67 | let frame = view.frame
68 | let newFrame = CGRect(x: newValue.x - frame.size.width / 2.0,
69 | y: newValue.y - frame.size.height / 2.0,
70 | width: frame.size.width,
71 | height: frame.size.height)
72 | view.frame = newFrame
73 | }
74 | }
75 | #else
76 | public var viewCenter: CGPoint {
77 | get {
78 | return view.center
79 | }
80 | set {
81 | view.center = newValue
82 | }
83 | }
84 | #endif
85 | }
86 |
87 | // MARK: - ActivityIndicator
88 | // Displays a NSProgressIndicator / UIActivityIndicatorView
89 | class ActivityIndicator: Indicator {
90 |
91 | #if os(macOS)
92 | private let activityIndicatorView: NSProgressIndicator
93 | #else
94 | private let activityIndicatorView: UIActivityIndicatorView
95 | #endif
96 | private var animatingCount = 0
97 |
98 | var view: IndicatorView {
99 | return activityIndicatorView
100 | }
101 |
102 | func startAnimatingView() {
103 | animatingCount += 1
104 | // Alrady animating
105 | if animatingCount == 1 {
106 | #if os(macOS)
107 | activityIndicatorView.startAnimation(nil)
108 | #else
109 | activityIndicatorView.startAnimating()
110 | #endif
111 | activityIndicatorView.isHidden = false
112 | }
113 | }
114 |
115 | func stopAnimatingView() {
116 | animatingCount = max(animatingCount - 1, 0)
117 | if animatingCount == 0 {
118 | #if os(macOS)
119 | activityIndicatorView.stopAnimation(nil)
120 | #else
121 | activityIndicatorView.stopAnimating()
122 | #endif
123 | activityIndicatorView.isHidden = true
124 | }
125 | }
126 |
127 | init() {
128 | #if os(macOS)
129 | activityIndicatorView = NSProgressIndicator(frame: CGRect(x: 0, y: 0, width: 16, height: 16))
130 | activityIndicatorView.controlSize = .small
131 | activityIndicatorView.style = .spinning
132 | #else
133 | #if os(tvOS)
134 | let indicatorStyle = UIActivityIndicatorViewStyle.white
135 | #else
136 | let indicatorStyle = UIActivityIndicatorViewStyle.gray
137 | #endif
138 | activityIndicatorView = UIActivityIndicatorView(activityIndicatorStyle:indicatorStyle)
139 | activityIndicatorView.autoresizingMask = [.flexibleLeftMargin, .flexibleRightMargin, .flexibleBottomMargin, .flexibleTopMargin]
140 | #endif
141 | }
142 | }
143 |
144 | // MARK: - ImageIndicator
145 | // Displays an ImageView. Supports gif
146 | class ImageIndicator: Indicator {
147 | private let animatedImageIndicatorView: ImageView
148 |
149 | var view: IndicatorView {
150 | return animatedImageIndicatorView
151 | }
152 |
153 | init?(imageData data: Data, processor: ImageProcessor = DefaultImageProcessor.default, options: KingfisherOptionsInfo = KingfisherEmptyOptionsInfo) {
154 |
155 | var options = options
156 | // Use normal image view to show animations, so we need to preload all animation data.
157 | if !options.preloadAllAnimationData {
158 | options.append(.preloadAllAnimationData)
159 | }
160 |
161 | guard let image = processor.process(item: .data(data), options: options) else {
162 | return nil
163 | }
164 |
165 | animatedImageIndicatorView = ImageView()
166 | animatedImageIndicatorView.image = image
167 | animatedImageIndicatorView.frame = CGRect(x: 0, y: 0, width: image.size.width, height: image.size.height)
168 |
169 | #if os(macOS)
170 | // Need for gif to animate on macOS
171 | self.animatedImageIndicatorView.imageScaling = .scaleNone
172 | self.animatedImageIndicatorView.canDrawSubviewsIntoLayer = true
173 | #else
174 | animatedImageIndicatorView.contentMode = .center
175 | animatedImageIndicatorView.autoresizingMask = [.flexibleLeftMargin,
176 | .flexibleRightMargin,
177 | .flexibleBottomMargin,
178 | .flexibleTopMargin]
179 | #endif
180 | }
181 |
182 | func startAnimatingView() {
183 | #if os(macOS)
184 | animatedImageIndicatorView.animates = true
185 | #else
186 | animatedImageIndicatorView.startAnimating()
187 | #endif
188 | animatedImageIndicatorView.isHidden = false
189 | }
190 |
191 | func stopAnimatingView() {
192 | #if os(macOS)
193 | animatedImageIndicatorView.animates = false
194 | #else
195 | animatedImageIndicatorView.stopAnimating()
196 | #endif
197 | animatedImageIndicatorView.isHidden = true
198 | }
199 | }
200 |
--------------------------------------------------------------------------------
/WRNavigationBar_swift/Pods/Kingfisher/Sources/Kingfisher.h:
--------------------------------------------------------------------------------
1 | //
2 | // Kingfisher.h
3 | // Kingfisher
4 | //
5 | // Created by Wei Wang on 15/4/6.
6 | //
7 | // Copyright (c) 2017 Wei Wang
8 | //
9 | // Permission is hereby granted, free of charge, to any person obtaining a copy
10 | // of this software and associated documentation files (the "Software"), to deal
11 | // in the Software without restriction, including without limitation the rights
12 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | // copies of the Software, and to permit persons to whom the Software is
14 | // furnished to do so, subject to the following conditions:
15 | //
16 | // The above copyright notice and this permission notice shall be included in
17 | // all copies or substantial portions of the Software.
18 | //
19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 | // THE SOFTWARE.
26 |
27 | #import
28 |
29 | //! Project version number for Kingfisher.
30 | FOUNDATION_EXPORT double KingfisherVersionNumber;
31 |
32 | //! Project version string for Kingfisher.
33 | FOUNDATION_EXPORT const unsigned char KingfisherVersionString[];
34 |
35 | // In this header, you should import all the public headers of your framework using statements like #import
36 |
37 |
38 |
--------------------------------------------------------------------------------
/WRNavigationBar_swift/Pods/Kingfisher/Sources/Kingfisher.swift:
--------------------------------------------------------------------------------
1 | //
2 | // Kingfisher.swift
3 | // Kingfisher
4 | //
5 | // Created by Wei Wang on 16/9/14.
6 | //
7 | // Copyright (c) 2017 Wei Wang
8 | //
9 | // Permission is hereby granted, free of charge, to any person obtaining a copy
10 | // of this software and associated documentation files (the "Software"), to deal
11 | // in the Software without restriction, including without limitation the rights
12 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | // copies of the Software, and to permit persons to whom the Software is
14 | // furnished to do so, subject to the following conditions:
15 | //
16 | // The above copyright notice and this permission notice shall be included in
17 | // all copies or substantial portions of the Software.
18 | //
19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 | // THE SOFTWARE.
26 |
27 | import Foundation
28 | import ImageIO
29 |
30 | #if os(macOS)
31 | import AppKit
32 | public typealias Image = NSImage
33 | public typealias View = NSView
34 | public typealias Color = NSColor
35 | public typealias ImageView = NSImageView
36 | public typealias Button = NSButton
37 | #else
38 | import UIKit
39 | public typealias Image = UIImage
40 | public typealias Color = UIColor
41 | #if !os(watchOS)
42 | public typealias ImageView = UIImageView
43 | public typealias View = UIView
44 | public typealias Button = UIButton
45 | #endif
46 | #endif
47 |
48 | public final class Kingfisher {
49 | public let base: Base
50 | public init(_ base: Base) {
51 | self.base = base
52 | }
53 | }
54 |
55 | /**
56 | A type that has Kingfisher extensions.
57 | */
58 | public protocol KingfisherCompatible {
59 | associatedtype CompatibleType
60 | var kf: CompatibleType { get }
61 | }
62 |
63 | public extension KingfisherCompatible {
64 | public var kf: Kingfisher {
65 | get { return Kingfisher(self) }
66 | }
67 | }
68 |
69 | extension Image: KingfisherCompatible { }
70 | #if !os(watchOS)
71 | extension ImageView: KingfisherCompatible { }
72 | extension Button: KingfisherCompatible { }
73 | #endif
74 |
--------------------------------------------------------------------------------
/WRNavigationBar_swift/Pods/Kingfisher/Sources/Placeholder.swift:
--------------------------------------------------------------------------------
1 | //
2 | // Placeholder.swift
3 | // Kingfisher
4 | //
5 | // Created by Tieme van Veen on 28/08/2017.
6 | //
7 | // Copyright (c) 2017 Wei Wang
8 | //
9 | // Permission is hereby granted, free of charge, to any person obtaining a copy
10 | // of this software and associated documentation files (the "Software"), to deal
11 | // in the Software without restriction, including without limitation the rights
12 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | // copies of the Software, and to permit persons to whom the Software is
14 | // furnished to do so, subject to the following conditions:
15 | //
16 | // The above copyright notice and this permission notice shall be included in
17 | // all copies or substantial portions of the Software.
18 | //
19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 | // THE SOFTWARE.
26 |
27 | #if os(macOS)
28 | import AppKit
29 | #else
30 | import UIKit
31 | #endif
32 |
33 |
34 | /// Represent a placeholder type which could be set while loading as well as
35 | /// loading finished without getting an image.
36 | public protocol Placeholder {
37 |
38 | /// How the placeholder should be added to a given image view.
39 | func add(to imageView: ImageView)
40 |
41 | /// How the placeholder should be removed from a given image view.
42 | func remove(from imageView: ImageView)
43 | }
44 |
45 | /// Default implementation of an image placeholder. The image will be set or
46 | /// reset directly for `image` property of the image view.
47 | extension Placeholder where Self: Image {
48 |
49 | /// How the placeholder should be added to a given image view.
50 | public func add(to imageView: ImageView) { imageView.image = self }
51 |
52 | /// How the placeholder should be removed from a given image view.
53 | public func remove(from imageView: ImageView) { imageView.image = nil }
54 | }
55 |
56 | extension Image: Placeholder {}
57 |
58 | /// Default implementation of an arbitrary view as placeholder. The view will be
59 | /// added as a subview when adding and be removed from its super view when removing.
60 | ///
61 | /// To use your customize View type as placeholder, simply let it conforming to
62 | /// `Placeholder` by `extension MyView: Placeholder {}`.
63 | extension Placeholder where Self: View {
64 |
65 | /// How the placeholder should be added to a given image view.
66 | public func add(to imageView: ImageView) {
67 | imageView.addSubview(self)
68 |
69 | self.translatesAutoresizingMaskIntoConstraints = false
70 | NSLayoutConstraint.activate([
71 | NSLayoutConstraint(item: self, attribute: .centerX, relatedBy: .equal, toItem: imageView, attribute: .centerX, multiplier: 1, constant: 0),
72 | NSLayoutConstraint(item: self, attribute: .centerY, relatedBy: .equal, toItem: imageView, attribute: .centerY, multiplier: 1, constant: 0),
73 | NSLayoutConstraint(item: self, attribute: .height, relatedBy: .equal, toItem: imageView, attribute: .height, multiplier: 1, constant: 0),
74 | NSLayoutConstraint(item: self, attribute: .width, relatedBy: .equal, toItem: imageView, attribute: .width, multiplier: 1, constant: 0)
75 | ])
76 | }
77 |
78 | /// How the placeholder should be removed from a given image view.
79 | public func remove(from imageView: ImageView) {
80 | self.removeFromSuperview()
81 | }
82 | }
83 |
--------------------------------------------------------------------------------
/WRNavigationBar_swift/Pods/Kingfisher/Sources/RequestModifier.swift:
--------------------------------------------------------------------------------
1 | //
2 | // RequestModifier.swift
3 | // Kingfisher
4 | //
5 | // Created by Wei Wang on 2016/09/05.
6 | //
7 | // Copyright (c) 2017 Wei Wang
8 | //
9 | // Permission is hereby granted, free of charge, to any person obtaining a copy
10 | // of this software and associated documentation files (the "Software"), to deal
11 | // in the Software without restriction, including without limitation the rights
12 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | // copies of the Software, and to permit persons to whom the Software is
14 | // furnished to do so, subject to the following conditions:
15 | //
16 | // The above copyright notice and this permission notice shall be included in
17 | // all copies or substantial portions of the Software.
18 | //
19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 | // THE SOFTWARE.
26 |
27 | import Foundation
28 |
29 | /// Request modifier of image downloader.
30 | public protocol ImageDownloadRequestModifier {
31 | func modified(for request: URLRequest) -> URLRequest?
32 | }
33 |
34 | struct NoModifier: ImageDownloadRequestModifier {
35 | static let `default` = NoModifier()
36 | private init() {}
37 | func modified(for request: URLRequest) -> URLRequest? {
38 | return request
39 | }
40 | }
41 |
42 | public struct AnyModifier: ImageDownloadRequestModifier {
43 |
44 | let block: (URLRequest) -> URLRequest?
45 |
46 | public func modified(for request: URLRequest) -> URLRequest? {
47 | return block(request)
48 | }
49 |
50 | public init(modify: @escaping (URLRequest) -> URLRequest? ) {
51 | block = modify
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/WRNavigationBar_swift/Pods/Kingfisher/Sources/Resource.swift:
--------------------------------------------------------------------------------
1 | //
2 | // Resource.swift
3 | // Kingfisher
4 | //
5 | // Created by Wei Wang on 15/4/6.
6 | //
7 | // Copyright (c) 2017 Wei Wang
8 | //
9 | // Permission is hereby granted, free of charge, to any person obtaining a copy
10 | // of this software and associated documentation files (the "Software"), to deal
11 | // in the Software without restriction, including without limitation the rights
12 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | // copies of the Software, and to permit persons to whom the Software is
14 | // furnished to do so, subject to the following conditions:
15 | //
16 | // The above copyright notice and this permission notice shall be included in
17 | // all copies or substantial portions of the Software.
18 | //
19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 | // THE SOFTWARE.
26 |
27 | import Foundation
28 |
29 |
30 | /// `Resource` protocol defines how to download and cache a resource from network.
31 | public protocol Resource {
32 | /// The key used in cache.
33 | var cacheKey: String { get }
34 |
35 | /// The target image URL.
36 | var downloadURL: URL { get }
37 | }
38 |
39 | /**
40 | ImageResource is a simple combination of `downloadURL` and `cacheKey`.
41 |
42 | When passed to image view set methods, Kingfisher will try to download the target
43 | image from the `downloadURL`, and then store it with the `cacheKey` as the key in cache.
44 | */
45 | public struct ImageResource: Resource {
46 | /// The key used in cache.
47 | public let cacheKey: String
48 |
49 | /// The target image URL.
50 | public let downloadURL: URL
51 |
52 | /**
53 | Create a resource.
54 |
55 | - parameter downloadURL: The target image URL.
56 | - parameter cacheKey: The cache key. If `nil`, Kingfisher will use the `absoluteString` of `downloadURL` as the key.
57 |
58 | - returns: A resource.
59 | */
60 | public init(downloadURL: URL, cacheKey: String? = nil) {
61 | self.downloadURL = downloadURL
62 | self.cacheKey = cacheKey ?? downloadURL.absoluteString
63 | }
64 | }
65 |
66 | /**
67 | URL conforms to `Resource` in Kingfisher.
68 | The `absoluteString` of this URL is used as `cacheKey`. And the URL itself will be used as `downloadURL`.
69 | If you need customize the url and/or cache key, use `ImageResource` instead.
70 | */
71 | extension URL: Resource {
72 | public var cacheKey: String { return absoluteString }
73 | public var downloadURL: URL { return self }
74 | }
75 |
--------------------------------------------------------------------------------
/WRNavigationBar_swift/Pods/Kingfisher/Sources/ThreadHelper.swift:
--------------------------------------------------------------------------------
1 | //
2 | // ThreadHelper.swift
3 | // Kingfisher
4 | //
5 | // Created by Wei Wang on 15/10/9.
6 | //
7 | // Copyright (c) 2017 Wei Wang
8 | //
9 | // Permission is hereby granted, free of charge, to any person obtaining a copy
10 | // of this software and associated documentation files (the "Software"), to deal
11 | // in the Software without restriction, including without limitation the rights
12 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | // copies of the Software, and to permit persons to whom the Software is
14 | // furnished to do so, subject to the following conditions:
15 | //
16 | // The above copyright notice and this permission notice shall be included in
17 | // all copies or substantial portions of the Software.
18 | //
19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 | // THE SOFTWARE.
26 |
27 | import Foundation
28 |
29 | extension DispatchQueue {
30 | // This method will dispatch the `block` to self.
31 | // If `self` is the main queue, and current thread is main thread, the block
32 | // will be invoked immediately instead of being dispatched.
33 | func safeAsync(_ block: @escaping ()->()) {
34 | if self === DispatchQueue.main && Thread.isMainThread {
35 | block()
36 | } else {
37 | async { block() }
38 | }
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/WRNavigationBar_swift/Pods/Manifest.lock:
--------------------------------------------------------------------------------
1 | PODS:
2 | - Kingfisher (4.3.1)
3 |
4 | DEPENDENCIES:
5 | - Kingfisher
6 |
7 | SPEC CHECKSUMS:
8 | Kingfisher: 75541c4b62f02e1fde6f9772303de3d9ebe8f5b3
9 |
10 | PODFILE CHECKSUM: eedd5593b4e862f4a6b0ebf6fd6f3f022a9f6b1d
11 |
12 | COCOAPODS: 1.3.1
13 |
--------------------------------------------------------------------------------
/WRNavigationBar_swift/Pods/Target Support Files/Kingfisher/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | ${EXECUTABLE_NAME}
9 | CFBundleIdentifier
10 | ${PRODUCT_BUNDLE_IDENTIFIER}
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | ${PRODUCT_NAME}
15 | CFBundlePackageType
16 | FMWK
17 | CFBundleShortVersionString
18 | 4.3.1
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | ${CURRENT_PROJECT_VERSION}
23 | NSPrincipalClass
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/WRNavigationBar_swift/Pods/Target Support Files/Kingfisher/Kingfisher-dummy.m:
--------------------------------------------------------------------------------
1 | #import
2 | @interface PodsDummy_Kingfisher : NSObject
3 | @end
4 | @implementation PodsDummy_Kingfisher
5 | @end
6 |
--------------------------------------------------------------------------------
/WRNavigationBar_swift/Pods/Target Support Files/Kingfisher/Kingfisher-prefix.pch:
--------------------------------------------------------------------------------
1 | #ifdef __OBJC__
2 | #import
3 | #else
4 | #ifndef FOUNDATION_EXPORT
5 | #if defined(__cplusplus)
6 | #define FOUNDATION_EXPORT extern "C"
7 | #else
8 | #define FOUNDATION_EXPORT extern
9 | #endif
10 | #endif
11 | #endif
12 |
13 |
--------------------------------------------------------------------------------
/WRNavigationBar_swift/Pods/Target Support Files/Kingfisher/Kingfisher-umbrella.h:
--------------------------------------------------------------------------------
1 | #ifdef __OBJC__
2 | #import
3 | #else
4 | #ifndef FOUNDATION_EXPORT
5 | #if defined(__cplusplus)
6 | #define FOUNDATION_EXPORT extern "C"
7 | #else
8 | #define FOUNDATION_EXPORT extern
9 | #endif
10 | #endif
11 | #endif
12 |
13 | #import "Kingfisher.h"
14 |
15 | FOUNDATION_EXPORT double KingfisherVersionNumber;
16 | FOUNDATION_EXPORT const unsigned char KingfisherVersionString[];
17 |
18 |
--------------------------------------------------------------------------------
/WRNavigationBar_swift/Pods/Target Support Files/Kingfisher/Kingfisher.modulemap:
--------------------------------------------------------------------------------
1 | framework module Kingfisher {
2 | umbrella header "Kingfisher-umbrella.h"
3 |
4 | export *
5 | module * { export * }
6 | }
7 |
--------------------------------------------------------------------------------
/WRNavigationBar_swift/Pods/Target Support Files/Kingfisher/Kingfisher.xcconfig:
--------------------------------------------------------------------------------
1 | CONFIGURATION_BUILD_DIR = $PODS_CONFIGURATION_BUILD_DIR/Kingfisher
2 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1
3 | HEADER_SEARCH_PATHS = "${PODS_ROOT}/Headers/Private" "${PODS_ROOT}/Headers/Public"
4 | OTHER_LDFLAGS = -framework "CFNetwork"
5 | OTHER_SWIFT_FLAGS = $(inherited) "-D" "COCOAPODS"
6 | PODS_BUILD_DIR = $BUILD_DIR
7 | PODS_CONFIGURATION_BUILD_DIR = $PODS_BUILD_DIR/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)
8 | PODS_ROOT = ${SRCROOT}
9 | PODS_TARGET_SRCROOT = ${PODS_ROOT}/Kingfisher
10 | PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.${PRODUCT_NAME:rfc1034identifier}
11 | SKIP_INSTALL = YES
12 | SWIFT_VERSION = 4.0
13 |
--------------------------------------------------------------------------------
/WRNavigationBar_swift/Pods/Target Support Files/Pods-WRNavigationBar_swift/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | ${EXECUTABLE_NAME}
9 | CFBundleIdentifier
10 | ${PRODUCT_BUNDLE_IDENTIFIER}
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | ${PRODUCT_NAME}
15 | CFBundlePackageType
16 | FMWK
17 | CFBundleShortVersionString
18 | 1.0.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | ${CURRENT_PROJECT_VERSION}
23 | NSPrincipalClass
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/WRNavigationBar_swift/Pods/Target Support Files/Pods-WRNavigationBar_swift/Pods-WRNavigationBar_swift-acknowledgements.markdown:
--------------------------------------------------------------------------------
1 | # Acknowledgements
2 | This application makes use of the following third party libraries:
3 |
4 | ## Kingfisher
5 |
6 | The MIT License (MIT)
7 |
8 | Copyright (c) 2017 Wei Wang
9 |
10 | Permission is hereby granted, free of charge, to any person obtaining a copy
11 | of this software and associated documentation files (the "Software"), to deal
12 | in the Software without restriction, including without limitation the rights
13 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14 | copies of the Software, and to permit persons to whom the Software is
15 | furnished to do so, subject to the following conditions:
16 |
17 | The above copyright notice and this permission notice shall be included in all
18 | copies or substantial portions of the Software.
19 |
20 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26 | SOFTWARE.
27 |
28 |
29 | Generated by CocoaPods - https://cocoapods.org
30 |
--------------------------------------------------------------------------------
/WRNavigationBar_swift/Pods/Target Support Files/Pods-WRNavigationBar_swift/Pods-WRNavigationBar_swift-acknowledgements.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | PreferenceSpecifiers
6 |
7 |
8 | FooterText
9 | This application makes use of the following third party libraries:
10 | Title
11 | Acknowledgements
12 | Type
13 | PSGroupSpecifier
14 |
15 |
16 | FooterText
17 | The MIT License (MIT)
18 |
19 | Copyright (c) 2017 Wei Wang
20 |
21 | Permission is hereby granted, free of charge, to any person obtaining a copy
22 | of this software and associated documentation files (the "Software"), to deal
23 | in the Software without restriction, including without limitation the rights
24 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
25 | copies of the Software, and to permit persons to whom the Software is
26 | furnished to do so, subject to the following conditions:
27 |
28 | The above copyright notice and this permission notice shall be included in all
29 | copies or substantial portions of the Software.
30 |
31 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
32 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
33 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
34 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
35 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
36 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
37 | SOFTWARE.
38 |
39 |
40 | License
41 | MIT
42 | Title
43 | Kingfisher
44 | Type
45 | PSGroupSpecifier
46 |
47 |
48 | FooterText
49 | Generated by CocoaPods - https://cocoapods.org
50 | Title
51 |
52 | Type
53 | PSGroupSpecifier
54 |
55 |
56 | StringsTable
57 | Acknowledgements
58 | Title
59 | Acknowledgements
60 |
61 |
62 |
--------------------------------------------------------------------------------
/WRNavigationBar_swift/Pods/Target Support Files/Pods-WRNavigationBar_swift/Pods-WRNavigationBar_swift-dummy.m:
--------------------------------------------------------------------------------
1 | #import
2 | @interface PodsDummy_Pods_WRNavigationBar_swift : NSObject
3 | @end
4 | @implementation PodsDummy_Pods_WRNavigationBar_swift
5 | @end
6 |
--------------------------------------------------------------------------------
/WRNavigationBar_swift/Pods/Target Support Files/Pods-WRNavigationBar_swift/Pods-WRNavigationBar_swift-frameworks.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | set -e
3 |
4 | echo "mkdir -p ${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}"
5 | mkdir -p "${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}"
6 |
7 | SWIFT_STDLIB_PATH="${DT_TOOLCHAIN_DIR}/usr/lib/swift/${PLATFORM_NAME}"
8 |
9 | # This protects against multiple targets copying the same framework dependency at the same time. The solution
10 | # was originally proposed here: https://lists.samba.org/archive/rsync/2008-February/020158.html
11 | RSYNC_PROTECT_TMP_FILES=(--filter "P .*.??????")
12 |
13 | install_framework()
14 | {
15 | if [ -r "${BUILT_PRODUCTS_DIR}/$1" ]; then
16 | local source="${BUILT_PRODUCTS_DIR}/$1"
17 | elif [ -r "${BUILT_PRODUCTS_DIR}/$(basename "$1")" ]; then
18 | local source="${BUILT_PRODUCTS_DIR}/$(basename "$1")"
19 | elif [ -r "$1" ]; then
20 | local source="$1"
21 | fi
22 |
23 | local destination="${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}"
24 |
25 | if [ -L "${source}" ]; then
26 | echo "Symlinked..."
27 | source="$(readlink "${source}")"
28 | fi
29 |
30 | # Use filter instead of exclude so missing patterns don't throw errors.
31 | echo "rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --filter \"- CVS/\" --filter \"- .svn/\" --filter \"- .git/\" --filter \"- .hg/\" --filter \"- Headers\" --filter \"- PrivateHeaders\" --filter \"- Modules\" \"${source}\" \"${destination}\""
32 | rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "${source}" "${destination}"
33 |
34 | local basename
35 | basename="$(basename -s .framework "$1")"
36 | binary="${destination}/${basename}.framework/${basename}"
37 | if ! [ -r "$binary" ]; then
38 | binary="${destination}/${basename}"
39 | fi
40 |
41 | # Strip invalid architectures so "fat" simulator / device frameworks work on device
42 | if [[ "$(file "$binary")" == *"dynamically linked shared library"* ]]; then
43 | strip_invalid_archs "$binary"
44 | fi
45 |
46 | # Resign the code if required by the build settings to avoid unstable apps
47 | code_sign_if_enabled "${destination}/$(basename "$1")"
48 |
49 | # Embed linked Swift runtime libraries. No longer necessary as of Xcode 7.
50 | if [ "${XCODE_VERSION_MAJOR}" -lt 7 ]; then
51 | local swift_runtime_libs
52 | swift_runtime_libs=$(xcrun otool -LX "$binary" | grep --color=never @rpath/libswift | sed -E s/@rpath\\/\(.+dylib\).*/\\1/g | uniq -u && exit ${PIPESTATUS[0]})
53 | for lib in $swift_runtime_libs; do
54 | echo "rsync -auv \"${SWIFT_STDLIB_PATH}/${lib}\" \"${destination}\""
55 | rsync -auv "${SWIFT_STDLIB_PATH}/${lib}" "${destination}"
56 | code_sign_if_enabled "${destination}/${lib}"
57 | done
58 | fi
59 | }
60 |
61 | # Copies the dSYM of a vendored framework
62 | install_dsym() {
63 | local source="$1"
64 | if [ -r "$source" ]; then
65 | echo "rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --filter \"- CVS/\" --filter \"- .svn/\" --filter \"- .git/\" --filter \"- .hg/\" --filter \"- Headers\" --filter \"- PrivateHeaders\" --filter \"- Modules\" \"${source}\" \"${DWARF_DSYM_FOLDER_PATH}\""
66 | rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "${source}" "${DWARF_DSYM_FOLDER_PATH}"
67 | fi
68 | }
69 |
70 | # Signs a framework with the provided identity
71 | code_sign_if_enabled() {
72 | if [ -n "${EXPANDED_CODE_SIGN_IDENTITY}" -a "${CODE_SIGNING_REQUIRED}" != "NO" -a "${CODE_SIGNING_ALLOWED}" != "NO" ]; then
73 | # Use the current code_sign_identitiy
74 | echo "Code Signing $1 with Identity ${EXPANDED_CODE_SIGN_IDENTITY_NAME}"
75 | local code_sign_cmd="/usr/bin/codesign --force --sign ${EXPANDED_CODE_SIGN_IDENTITY} ${OTHER_CODE_SIGN_FLAGS} --preserve-metadata=identifier,entitlements '$1'"
76 |
77 | if [ "${COCOAPODS_PARALLEL_CODE_SIGN}" == "true" ]; then
78 | code_sign_cmd="$code_sign_cmd &"
79 | fi
80 | echo "$code_sign_cmd"
81 | eval "$code_sign_cmd"
82 | fi
83 | }
84 |
85 | # Strip invalid architectures
86 | strip_invalid_archs() {
87 | binary="$1"
88 | # Get architectures for current file
89 | archs="$(lipo -info "$binary" | rev | cut -d ':' -f1 | rev)"
90 | stripped=""
91 | for arch in $archs; do
92 | if ! [[ "${ARCHS}" == *"$arch"* ]]; then
93 | # Strip non-valid architectures in-place
94 | lipo -remove "$arch" -output "$binary" "$binary" || exit 1
95 | stripped="$stripped $arch"
96 | fi
97 | done
98 | if [[ "$stripped" ]]; then
99 | echo "Stripped $binary of architectures:$stripped"
100 | fi
101 | }
102 |
103 |
104 | if [[ "$CONFIGURATION" == "Debug" ]]; then
105 | install_framework "${BUILT_PRODUCTS_DIR}/Kingfisher/Kingfisher.framework"
106 | fi
107 | if [[ "$CONFIGURATION" == "Release" ]]; then
108 | install_framework "${BUILT_PRODUCTS_DIR}/Kingfisher/Kingfisher.framework"
109 | fi
110 | if [ "${COCOAPODS_PARALLEL_CODE_SIGN}" == "true" ]; then
111 | wait
112 | fi
113 |
--------------------------------------------------------------------------------
/WRNavigationBar_swift/Pods/Target Support Files/Pods-WRNavigationBar_swift/Pods-WRNavigationBar_swift-resources.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | set -e
3 |
4 | mkdir -p "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}"
5 |
6 | RESOURCES_TO_COPY=${PODS_ROOT}/resources-to-copy-${TARGETNAME}.txt
7 | > "$RESOURCES_TO_COPY"
8 |
9 | XCASSET_FILES=()
10 |
11 | # This protects against multiple targets copying the same framework dependency at the same time. The solution
12 | # was originally proposed here: https://lists.samba.org/archive/rsync/2008-February/020158.html
13 | RSYNC_PROTECT_TMP_FILES=(--filter "P .*.??????")
14 |
15 | case "${TARGETED_DEVICE_FAMILY}" in
16 | 1,2)
17 | TARGET_DEVICE_ARGS="--target-device ipad --target-device iphone"
18 | ;;
19 | 1)
20 | TARGET_DEVICE_ARGS="--target-device iphone"
21 | ;;
22 | 2)
23 | TARGET_DEVICE_ARGS="--target-device ipad"
24 | ;;
25 | 3)
26 | TARGET_DEVICE_ARGS="--target-device tv"
27 | ;;
28 | 4)
29 | TARGET_DEVICE_ARGS="--target-device watch"
30 | ;;
31 | *)
32 | TARGET_DEVICE_ARGS="--target-device mac"
33 | ;;
34 | esac
35 |
36 | install_resource()
37 | {
38 | if [[ "$1" = /* ]] ; then
39 | RESOURCE_PATH="$1"
40 | else
41 | RESOURCE_PATH="${PODS_ROOT}/$1"
42 | fi
43 | if [[ ! -e "$RESOURCE_PATH" ]] ; then
44 | cat << EOM
45 | error: Resource "$RESOURCE_PATH" not found. Run 'pod install' to update the copy resources script.
46 | EOM
47 | exit 1
48 | fi
49 | case $RESOURCE_PATH in
50 | *.storyboard)
51 | echo "ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile ${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .storyboard`.storyboardc $RESOURCE_PATH --sdk ${SDKROOT} ${TARGET_DEVICE_ARGS}" || true
52 | ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .storyboard`.storyboardc" "$RESOURCE_PATH" --sdk "${SDKROOT}" ${TARGET_DEVICE_ARGS}
53 | ;;
54 | *.xib)
55 | echo "ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile ${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .xib`.nib $RESOURCE_PATH --sdk ${SDKROOT} ${TARGET_DEVICE_ARGS}" || true
56 | ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .xib`.nib" "$RESOURCE_PATH" --sdk "${SDKROOT}" ${TARGET_DEVICE_ARGS}
57 | ;;
58 | *.framework)
59 | echo "mkdir -p ${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" || true
60 | mkdir -p "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}"
61 | echo "rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" $RESOURCE_PATH ${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" || true
62 | rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}"
63 | ;;
64 | *.xcdatamodel)
65 | echo "xcrun momc \"$RESOURCE_PATH\" \"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH"`.mom\"" || true
66 | xcrun momc "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcdatamodel`.mom"
67 | ;;
68 | *.xcdatamodeld)
69 | echo "xcrun momc \"$RESOURCE_PATH\" \"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcdatamodeld`.momd\"" || true
70 | xcrun momc "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcdatamodeld`.momd"
71 | ;;
72 | *.xcmappingmodel)
73 | echo "xcrun mapc \"$RESOURCE_PATH\" \"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcmappingmodel`.cdm\"" || true
74 | xcrun mapc "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcmappingmodel`.cdm"
75 | ;;
76 | *.xcassets)
77 | ABSOLUTE_XCASSET_FILE="$RESOURCE_PATH"
78 | XCASSET_FILES+=("$ABSOLUTE_XCASSET_FILE")
79 | ;;
80 | *)
81 | echo "$RESOURCE_PATH" || true
82 | echo "$RESOURCE_PATH" >> "$RESOURCES_TO_COPY"
83 | ;;
84 | esac
85 | }
86 |
87 | mkdir -p "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}"
88 | rsync -avr --copy-links --no-relative --exclude '*/.svn/*' --files-from="$RESOURCES_TO_COPY" / "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}"
89 | if [[ "${ACTION}" == "install" ]] && [[ "${SKIP_INSTALL}" == "NO" ]]; then
90 | mkdir -p "${INSTALL_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}"
91 | rsync -avr --copy-links --no-relative --exclude '*/.svn/*' --files-from="$RESOURCES_TO_COPY" / "${INSTALL_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}"
92 | fi
93 | rm -f "$RESOURCES_TO_COPY"
94 |
95 | if [[ -n "${WRAPPER_EXTENSION}" ]] && [ "`xcrun --find actool`" ] && [ -n "$XCASSET_FILES" ]
96 | then
97 | # Find all other xcassets (this unfortunately includes those of path pods and other targets).
98 | OTHER_XCASSETS=$(find "$PWD" -iname "*.xcassets" -type d)
99 | while read line; do
100 | if [[ $line != "${PODS_ROOT}*" ]]; then
101 | XCASSET_FILES+=("$line")
102 | fi
103 | done <<<"$OTHER_XCASSETS"
104 |
105 | printf "%s\0" "${XCASSET_FILES[@]}" | xargs -0 xcrun actool --output-format human-readable-text --notices --warnings --platform "${PLATFORM_NAME}" --minimum-deployment-target "${!DEPLOYMENT_TARGET_SETTING_NAME}" ${TARGET_DEVICE_ARGS} --compress-pngs --compile "${BUILT_PRODUCTS_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}"
106 | fi
107 |
--------------------------------------------------------------------------------
/WRNavigationBar_swift/Pods/Target Support Files/Pods-WRNavigationBar_swift/Pods-WRNavigationBar_swift-umbrella.h:
--------------------------------------------------------------------------------
1 | #ifdef __OBJC__
2 | #import
3 | #else
4 | #ifndef FOUNDATION_EXPORT
5 | #if defined(__cplusplus)
6 | #define FOUNDATION_EXPORT extern "C"
7 | #else
8 | #define FOUNDATION_EXPORT extern
9 | #endif
10 | #endif
11 | #endif
12 |
13 |
14 | FOUNDATION_EXPORT double Pods_WRNavigationBar_swiftVersionNumber;
15 | FOUNDATION_EXPORT const unsigned char Pods_WRNavigationBar_swiftVersionString[];
16 |
17 |
--------------------------------------------------------------------------------
/WRNavigationBar_swift/Pods/Target Support Files/Pods-WRNavigationBar_swift/Pods-WRNavigationBar_swift.debug.xcconfig:
--------------------------------------------------------------------------------
1 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES
2 | FRAMEWORK_SEARCH_PATHS = $(inherited) "$PODS_CONFIGURATION_BUILD_DIR/Kingfisher"
3 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1
4 | LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks'
5 | OTHER_CFLAGS = $(inherited) -iquote "$PODS_CONFIGURATION_BUILD_DIR/Kingfisher/Kingfisher.framework/Headers"
6 | OTHER_LDFLAGS = $(inherited) -framework "Kingfisher"
7 | OTHER_SWIFT_FLAGS = $(inherited) "-D" "COCOAPODS"
8 | PODS_BUILD_DIR = $BUILD_DIR
9 | PODS_CONFIGURATION_BUILD_DIR = $PODS_BUILD_DIR/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)
10 | PODS_PODFILE_DIR_PATH = ${SRCROOT}/.
11 | PODS_ROOT = ${SRCROOT}/Pods
12 |
--------------------------------------------------------------------------------
/WRNavigationBar_swift/Pods/Target Support Files/Pods-WRNavigationBar_swift/Pods-WRNavigationBar_swift.modulemap:
--------------------------------------------------------------------------------
1 | framework module Pods_WRNavigationBar_swift {
2 | umbrella header "Pods-WRNavigationBar_swift-umbrella.h"
3 |
4 | export *
5 | module * { export * }
6 | }
7 |
--------------------------------------------------------------------------------
/WRNavigationBar_swift/Pods/Target Support Files/Pods-WRNavigationBar_swift/Pods-WRNavigationBar_swift.release.xcconfig:
--------------------------------------------------------------------------------
1 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES
2 | FRAMEWORK_SEARCH_PATHS = $(inherited) "$PODS_CONFIGURATION_BUILD_DIR/Kingfisher"
3 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1
4 | LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks'
5 | OTHER_CFLAGS = $(inherited) -iquote "$PODS_CONFIGURATION_BUILD_DIR/Kingfisher/Kingfisher.framework/Headers"
6 | OTHER_LDFLAGS = $(inherited) -framework "Kingfisher"
7 | OTHER_SWIFT_FLAGS = $(inherited) "-D" "COCOAPODS"
8 | PODS_BUILD_DIR = $BUILD_DIR
9 | PODS_CONFIGURATION_BUILD_DIR = $PODS_BUILD_DIR/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)
10 | PODS_PODFILE_DIR_PATH = ${SRCROOT}/.
11 | PODS_ROOT = ${SRCROOT}/Pods
12 |
--------------------------------------------------------------------------------
/WRNavigationBar_swift/WRNavigationBar_swift.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/WRNavigationBar_swift/WRNavigationBar_swift.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/WRNavigationBar_swift/WRNavigationBar_swift/AppDelegate.swift:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.swift
3 | // WRNavigationBar_swift
4 | //
5 | // Created by wangrui on 2017/4/19.
6 | // Copyright © 2017年 wangrui. All rights reserved.
7 | //
8 | // Github地址:https://github.com/wangrui460/WRNavigationBar_swift
9 |
10 | import UIKit
11 |
12 | let MainNavBarColor = UIColor.init(red: 0/255.0, green: 175/255.0, blue: 240/255.0, alpha: 1)
13 | let kScreenWidth = UIScreen.main.bounds.width
14 | let kScreenHeight = UIScreen.main.bounds.height
15 | let kTabBarHeight = 49
16 | let kNavBarHeight = 44
17 |
18 | @UIApplicationMain
19 | class AppDelegate: UIResponder, UIApplicationDelegate {
20 |
21 | var window: UIWindow?
22 |
23 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool
24 | {
25 | window = UIWindow.init(frame: UIScreen.main.bounds)
26 | window?.backgroundColor = UIColor.white
27 |
28 | let firstNav = BaseNavigationController.init(rootViewController: NormalListController())
29 | let secondNav = BaseNavigationController.init(rootViewController: CustomListController())
30 | let thirdNav = BaseNavigationController.init(rootViewController: MoveListController())
31 | let tabBarVC = UITabBarController.init()
32 | tabBarVC.viewControllers = [firstNav, secondNav, thirdNav]
33 | setTabBarItems(tabBarVC: tabBarVC)
34 |
35 | window?.rootViewController = tabBarVC
36 | setNavBarAppearence()
37 | window?.makeKeyAndVisible()
38 |
39 | return true
40 | }
41 |
42 | func setTabBarItems(tabBarVC:UITabBarController)
43 | {
44 | let titles = ["常用", "自定义导航栏", "移动导航栏"];
45 | let normalImages = ["mine",
46 | "mine",
47 | "mine"];
48 | let highlightImages = ["mineHighlight",
49 | "mineHighlight",
50 | "mineHighlight"];
51 | for (index, item) in tabBarVC.tabBar.items!.enumerated()
52 | {
53 | item.title = titles[index]
54 | item.image = UIImage(named: normalImages[index])?.withRenderingMode(.alwaysOriginal)
55 | item.selectedImage = UIImage(named: highlightImages[index])?.withRenderingMode(.alwaysOriginal)
56 | }
57 | }
58 |
59 | func setNavBarAppearence()
60 | {
61 | // 设置导航栏默认的背景颜色
62 | WRNavigationBar.defaultNavBarBarTintColor = UIColor.init(red: 0/255.0, green: 175/255.0, blue: 240/255.0, alpha: 1)
63 | // 设置导航栏所有按钮的默认颜色
64 | WRNavigationBar.defaultNavBarTintColor = .white
65 | // 设置导航栏标题默认颜色
66 | WRNavigationBar.defaultNavBarTitleColor = .white
67 | // 统一设置状态栏样式
68 | WRNavigationBar.defaultStatusBarStyle = .lightContent
69 | // 如果需要设置导航栏底部分割线隐藏,可以在这里统一设置
70 | WRNavigationBar.defaultShadowImageHidden = true
71 | }
72 | }
73 |
74 |
--------------------------------------------------------------------------------
/WRNavigationBar_swift/WRNavigationBar_swift/Assets.xcassets/AppIcon.appiconset/180wr.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wangrui460/WRNavigationBar_swift/e9e9bd77d0dc856dd872937351e2024c5407d74f/WRNavigationBar_swift/WRNavigationBar_swift/Assets.xcassets/AppIcon.appiconset/180wr.png
--------------------------------------------------------------------------------
/WRNavigationBar_swift/WRNavigationBar_swift/Assets.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "iphone",
5 | "size" : "20x20",
6 | "scale" : "2x"
7 | },
8 | {
9 | "idiom" : "iphone",
10 | "size" : "20x20",
11 | "scale" : "3x"
12 | },
13 | {
14 | "idiom" : "iphone",
15 | "size" : "29x29",
16 | "scale" : "2x"
17 | },
18 | {
19 | "idiom" : "iphone",
20 | "size" : "29x29",
21 | "scale" : "3x"
22 | },
23 | {
24 | "idiom" : "iphone",
25 | "size" : "40x40",
26 | "scale" : "2x"
27 | },
28 | {
29 | "idiom" : "iphone",
30 | "size" : "40x40",
31 | "scale" : "3x"
32 | },
33 | {
34 | "size" : "60x60",
35 | "idiom" : "iphone",
36 | "filename" : "wr120@2x.png",
37 | "scale" : "2x"
38 | },
39 | {
40 | "size" : "60x60",
41 | "idiom" : "iphone",
42 | "filename" : "180wr.png",
43 | "scale" : "3x"
44 | },
45 | {
46 | "idiom" : "ios-marketing",
47 | "size" : "1024x1024",
48 | "scale" : "1x"
49 | }
50 | ],
51 | "info" : {
52 | "version" : 1,
53 | "author" : "xcode"
54 | }
55 | }
--------------------------------------------------------------------------------
/WRNavigationBar_swift/WRNavigationBar_swift/Assets.xcassets/AppIcon.appiconset/wr120@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wangrui460/WRNavigationBar_swift/e9e9bd77d0dc856dd872937351e2024c5407d74f/WRNavigationBar_swift/WRNavigationBar_swift/Assets.xcassets/AppIcon.appiconset/wr120@2x.png
--------------------------------------------------------------------------------
/WRNavigationBar_swift/WRNavigationBar_swift/Assets.xcassets/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "info" : {
3 | "version" : 1,
4 | "author" : "xcode"
5 | }
6 | }
--------------------------------------------------------------------------------
/WRNavigationBar_swift/WRNavigationBar_swift/Assets.xcassets/bottomImage.imageset/938A54DAB0905290EBBE392AE73286DC.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wangrui460/WRNavigationBar_swift/e9e9bd77d0dc856dd872937351e2024c5407d74f/WRNavigationBar_swift/WRNavigationBar_swift/Assets.xcassets/bottomImage.imageset/938A54DAB0905290EBBE392AE73286DC.jpg
--------------------------------------------------------------------------------
/WRNavigationBar_swift/WRNavigationBar_swift/Assets.xcassets/bottomImage.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "filename" : "938A54DAB0905290EBBE392AE73286DC.jpg",
6 | "scale" : "1x"
7 | },
8 | {
9 | "idiom" : "universal",
10 | "scale" : "2x"
11 | },
12 | {
13 | "idiom" : "universal",
14 | "scale" : "3x"
15 | }
16 | ],
17 | "info" : {
18 | "version" : 1,
19 | "author" : "xcode"
20 | }
21 | }
--------------------------------------------------------------------------------
/WRNavigationBar_swift/WRNavigationBar_swift/Assets.xcassets/image1.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "filename" : "image1.jpg",
6 | "scale" : "1x"
7 | },
8 | {
9 | "idiom" : "universal",
10 | "scale" : "2x"
11 | },
12 | {
13 | "idiom" : "universal",
14 | "scale" : "3x"
15 | }
16 | ],
17 | "info" : {
18 | "version" : 1,
19 | "author" : "xcode"
20 | }
21 | }
--------------------------------------------------------------------------------
/WRNavigationBar_swift/WRNavigationBar_swift/Assets.xcassets/image1.imageset/image1.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wangrui460/WRNavigationBar_swift/e9e9bd77d0dc856dd872937351e2024c5407d74f/WRNavigationBar_swift/WRNavigationBar_swift/Assets.xcassets/image1.imageset/image1.jpg
--------------------------------------------------------------------------------
/WRNavigationBar_swift/WRNavigationBar_swift/Assets.xcassets/image2.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "filename" : "image2.jpg",
6 | "scale" : "1x"
7 | },
8 | {
9 | "idiom" : "universal",
10 | "scale" : "2x"
11 | },
12 | {
13 | "idiom" : "universal",
14 | "scale" : "3x"
15 | }
16 | ],
17 | "info" : {
18 | "version" : 1,
19 | "author" : "xcode"
20 | }
21 | }
--------------------------------------------------------------------------------
/WRNavigationBar_swift/WRNavigationBar_swift/Assets.xcassets/image2.imageset/image2.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wangrui460/WRNavigationBar_swift/e9e9bd77d0dc856dd872937351e2024c5407d74f/WRNavigationBar_swift/WRNavigationBar_swift/Assets.xcassets/image2.imageset/image2.jpg
--------------------------------------------------------------------------------
/WRNavigationBar_swift/WRNavigationBar_swift/Assets.xcassets/image3.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "filename" : "DF0999B79D020D160165A612636482E9.jpg",
6 | "scale" : "1x"
7 | },
8 | {
9 | "idiom" : "universal",
10 | "scale" : "2x"
11 | },
12 | {
13 | "idiom" : "universal",
14 | "scale" : "3x"
15 | }
16 | ],
17 | "info" : {
18 | "version" : 1,
19 | "author" : "xcode"
20 | }
21 | }
--------------------------------------------------------------------------------
/WRNavigationBar_swift/WRNavigationBar_swift/Assets.xcassets/image3.imageset/DF0999B79D020D160165A612636482E9.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wangrui460/WRNavigationBar_swift/e9e9bd77d0dc856dd872937351e2024c5407d74f/WRNavigationBar_swift/WRNavigationBar_swift/Assets.xcassets/image3.imageset/DF0999B79D020D160165A612636482E9.jpg
--------------------------------------------------------------------------------
/WRNavigationBar_swift/WRNavigationBar_swift/Assets.xcassets/image4.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "filename" : "椭圆 2.png",
6 | "scale" : "1x"
7 | },
8 | {
9 | "idiom" : "universal",
10 | "scale" : "2x"
11 | },
12 | {
13 | "idiom" : "universal",
14 | "scale" : "3x"
15 | }
16 | ],
17 | "info" : {
18 | "version" : 1,
19 | "author" : "xcode"
20 | }
21 | }
--------------------------------------------------------------------------------
/WRNavigationBar_swift/WRNavigationBar_swift/Assets.xcassets/image4.imageset/椭圆 2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wangrui460/WRNavigationBar_swift/e9e9bd77d0dc856dd872937351e2024c5407d74f/WRNavigationBar_swift/WRNavigationBar_swift/Assets.xcassets/image4.imageset/椭圆 2.png
--------------------------------------------------------------------------------
/WRNavigationBar_swift/WRNavigationBar_swift/Assets.xcassets/image5.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "filename" : "我3.png",
6 | "scale" : "1x"
7 | },
8 | {
9 | "idiom" : "universal",
10 | "scale" : "2x"
11 | },
12 | {
13 | "idiom" : "universal",
14 | "scale" : "3x"
15 | }
16 | ],
17 | "info" : {
18 | "version" : 1,
19 | "author" : "xcode"
20 | }
21 | }
--------------------------------------------------------------------------------
/WRNavigationBar_swift/WRNavigationBar_swift/Assets.xcassets/image5.imageset/我3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wangrui460/WRNavigationBar_swift/e9e9bd77d0dc856dd872937351e2024c5407d74f/WRNavigationBar_swift/WRNavigationBar_swift/Assets.xcassets/image5.imageset/我3.png
--------------------------------------------------------------------------------
/WRNavigationBar_swift/WRNavigationBar_swift/Assets.xcassets/image6.imageset/B56C24FF94B6EB94E1DD1931343B37D3.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wangrui460/WRNavigationBar_swift/e9e9bd77d0dc856dd872937351e2024c5407d74f/WRNavigationBar_swift/WRNavigationBar_swift/Assets.xcassets/image6.imageset/B56C24FF94B6EB94E1DD1931343B37D3.jpg
--------------------------------------------------------------------------------
/WRNavigationBar_swift/WRNavigationBar_swift/Assets.xcassets/image6.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "filename" : "B56C24FF94B6EB94E1DD1931343B37D3.jpg",
6 | "scale" : "1x"
7 | },
8 | {
9 | "idiom" : "universal",
10 | "scale" : "2x"
11 | },
12 | {
13 | "idiom" : "universal",
14 | "scale" : "3x"
15 | }
16 | ],
17 | "info" : {
18 | "version" : 1,
19 | "author" : "xcode"
20 | }
21 | }
--------------------------------------------------------------------------------
/WRNavigationBar_swift/WRNavigationBar_swift/Assets.xcassets/image7.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "filename" : "u=2864424897,2473674229&fm=26&gp=0.jpg",
6 | "scale" : "1x"
7 | },
8 | {
9 | "idiom" : "universal",
10 | "scale" : "2x"
11 | },
12 | {
13 | "idiom" : "universal",
14 | "scale" : "3x"
15 | }
16 | ],
17 | "info" : {
18 | "version" : 1,
19 | "author" : "xcode"
20 | }
21 | }
--------------------------------------------------------------------------------
/WRNavigationBar_swift/WRNavigationBar_swift/Assets.xcassets/image7.imageset/u=2864424897,2473674229&fm=26&gp=0.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wangrui460/WRNavigationBar_swift/e9e9bd77d0dc856dd872937351e2024c5407d74f/WRNavigationBar_swift/WRNavigationBar_swift/Assets.xcassets/image7.imageset/u=2864424897,2473674229&fm=26&gp=0.jpg
--------------------------------------------------------------------------------
/WRNavigationBar_swift/WRNavigationBar_swift/Assets.xcassets/image8.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "filename" : "cad334853a19ab63f278ed8532ff8ae1.jpeg",
6 | "scale" : "1x"
7 | },
8 | {
9 | "idiom" : "universal",
10 | "scale" : "2x"
11 | },
12 | {
13 | "idiom" : "universal",
14 | "scale" : "3x"
15 | }
16 | ],
17 | "info" : {
18 | "version" : 1,
19 | "author" : "xcode"
20 | }
21 | }
--------------------------------------------------------------------------------
/WRNavigationBar_swift/WRNavigationBar_swift/Assets.xcassets/image8.imageset/cad334853a19ab63f278ed8532ff8ae1.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wangrui460/WRNavigationBar_swift/e9e9bd77d0dc856dd872937351e2024c5407d74f/WRNavigationBar_swift/WRNavigationBar_swift/Assets.xcassets/image8.imageset/cad334853a19ab63f278ed8532ff8ae1.jpeg
--------------------------------------------------------------------------------
/WRNavigationBar_swift/WRNavigationBar_swift/Assets.xcassets/imageNav.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "filename" : "u=1206318416,27195661&fm=26&gp=0.jpg",
6 | "scale" : "1x"
7 | },
8 | {
9 | "idiom" : "universal",
10 | "scale" : "2x"
11 | },
12 | {
13 | "idiom" : "universal",
14 | "scale" : "3x"
15 | }
16 | ],
17 | "info" : {
18 | "version" : 1,
19 | "author" : "xcode"
20 | }
21 | }
--------------------------------------------------------------------------------
/WRNavigationBar_swift/WRNavigationBar_swift/Assets.xcassets/imageNav.imageset/u=1206318416,27195661&fm=26&gp=0.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wangrui460/WRNavigationBar_swift/e9e9bd77d0dc856dd872937351e2024c5407d74f/WRNavigationBar_swift/WRNavigationBar_swift/Assets.xcassets/imageNav.imageset/u=1206318416,27195661&fm=26&gp=0.jpg
--------------------------------------------------------------------------------
/WRNavigationBar_swift/WRNavigationBar_swift/Assets.xcassets/localImg10.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "filename" : "localImg10.jpg",
6 | "scale" : "1x"
7 | },
8 | {
9 | "idiom" : "universal",
10 | "scale" : "2x"
11 | },
12 | {
13 | "idiom" : "universal",
14 | "scale" : "3x"
15 | }
16 | ],
17 | "info" : {
18 | "version" : 1,
19 | "author" : "xcode"
20 | }
21 | }
--------------------------------------------------------------------------------
/WRNavigationBar_swift/WRNavigationBar_swift/Assets.xcassets/localImg10.imageset/localImg10.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wangrui460/WRNavigationBar_swift/e9e9bd77d0dc856dd872937351e2024c5407d74f/WRNavigationBar_swift/WRNavigationBar_swift/Assets.xcassets/localImg10.imageset/localImg10.jpg
--------------------------------------------------------------------------------
/WRNavigationBar_swift/WRNavigationBar_swift/Assets.xcassets/localImg6.imageset/6.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wangrui460/WRNavigationBar_swift/e9e9bd77d0dc856dd872937351e2024c5407d74f/WRNavigationBar_swift/WRNavigationBar_swift/Assets.xcassets/localImg6.imageset/6.jpg
--------------------------------------------------------------------------------
/WRNavigationBar_swift/WRNavigationBar_swift/Assets.xcassets/localImg6.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "filename" : "6.jpg",
6 | "scale" : "1x"
7 | },
8 | {
9 | "idiom" : "universal",
10 | "scale" : "2x"
11 | },
12 | {
13 | "idiom" : "universal",
14 | "scale" : "3x"
15 | }
16 | ],
17 | "info" : {
18 | "version" : 1,
19 | "author" : "xcode"
20 | }
21 | }
--------------------------------------------------------------------------------
/WRNavigationBar_swift/WRNavigationBar_swift/Assets.xcassets/localImg7.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "filename" : "localImg7.jpg",
6 | "scale" : "1x"
7 | },
8 | {
9 | "idiom" : "universal",
10 | "scale" : "2x"
11 | },
12 | {
13 | "idiom" : "universal",
14 | "scale" : "3x"
15 | }
16 | ],
17 | "info" : {
18 | "version" : 1,
19 | "author" : "xcode"
20 | }
21 | }
--------------------------------------------------------------------------------
/WRNavigationBar_swift/WRNavigationBar_swift/Assets.xcassets/localImg7.imageset/localImg7.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wangrui460/WRNavigationBar_swift/e9e9bd77d0dc856dd872937351e2024c5407d74f/WRNavigationBar_swift/WRNavigationBar_swift/Assets.xcassets/localImg7.imageset/localImg7.jpg
--------------------------------------------------------------------------------
/WRNavigationBar_swift/WRNavigationBar_swift/Assets.xcassets/localImg8.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "filename" : "localImg8.jpg",
6 | "scale" : "1x"
7 | },
8 | {
9 | "idiom" : "universal",
10 | "scale" : "2x"
11 | },
12 | {
13 | "idiom" : "universal",
14 | "scale" : "3x"
15 | }
16 | ],
17 | "info" : {
18 | "version" : 1,
19 | "author" : "xcode"
20 | }
21 | }
--------------------------------------------------------------------------------
/WRNavigationBar_swift/WRNavigationBar_swift/Assets.xcassets/localImg8.imageset/localImg8.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wangrui460/WRNavigationBar_swift/e9e9bd77d0dc856dd872937351e2024c5407d74f/WRNavigationBar_swift/WRNavigationBar_swift/Assets.xcassets/localImg8.imageset/localImg8.jpg
--------------------------------------------------------------------------------
/WRNavigationBar_swift/WRNavigationBar_swift/Assets.xcassets/localImg9.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "filename" : "localImg9.jpg",
6 | "scale" : "1x"
7 | },
8 | {
9 | "idiom" : "universal",
10 | "scale" : "2x"
11 | },
12 | {
13 | "idiom" : "universal",
14 | "scale" : "3x"
15 | }
16 | ],
17 | "info" : {
18 | "version" : 1,
19 | "author" : "xcode"
20 | }
21 | }
--------------------------------------------------------------------------------
/WRNavigationBar_swift/WRNavigationBar_swift/Assets.xcassets/localImg9.imageset/localImg9.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wangrui460/WRNavigationBar_swift/e9e9bd77d0dc856dd872937351e2024c5407d74f/WRNavigationBar_swift/WRNavigationBar_swift/Assets.xcassets/localImg9.imageset/localImg9.jpg
--------------------------------------------------------------------------------
/WRNavigationBar_swift/WRNavigationBar_swift/Assets.xcassets/millcolorGrad.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "scale" : "1x"
6 | },
7 | {
8 | "idiom" : "universal",
9 | "scale" : "2x"
10 | },
11 | {
12 | "idiom" : "universal",
13 | "filename" : "millcolorGrad.png",
14 | "scale" : "3x"
15 | }
16 | ],
17 | "info" : {
18 | "version" : 1,
19 | "author" : "xcode"
20 | }
21 | }
--------------------------------------------------------------------------------
/WRNavigationBar_swift/WRNavigationBar_swift/Assets.xcassets/millcolorGrad.imageset/millcolorGrad.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wangrui460/WRNavigationBar_swift/e9e9bd77d0dc856dd872937351e2024c5407d74f/WRNavigationBar_swift/WRNavigationBar_swift/Assets.xcassets/millcolorGrad.imageset/millcolorGrad.png
--------------------------------------------------------------------------------
/WRNavigationBar_swift/WRNavigationBar_swift/Assets.xcassets/mine.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "scale" : "1x"
6 | },
7 | {
8 | "idiom" : "universal",
9 | "filename" : "mine@2x.png",
10 | "scale" : "2x"
11 | },
12 | {
13 | "idiom" : "universal",
14 | "filename" : "mine@3x.png",
15 | "scale" : "3x"
16 | }
17 | ],
18 | "info" : {
19 | "version" : 1,
20 | "author" : "xcode"
21 | }
22 | }
--------------------------------------------------------------------------------
/WRNavigationBar_swift/WRNavigationBar_swift/Assets.xcassets/mine.imageset/mine@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wangrui460/WRNavigationBar_swift/e9e9bd77d0dc856dd872937351e2024c5407d74f/WRNavigationBar_swift/WRNavigationBar_swift/Assets.xcassets/mine.imageset/mine@2x.png
--------------------------------------------------------------------------------
/WRNavigationBar_swift/WRNavigationBar_swift/Assets.xcassets/mine.imageset/mine@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wangrui460/WRNavigationBar_swift/e9e9bd77d0dc856dd872937351e2024c5407d74f/WRNavigationBar_swift/WRNavigationBar_swift/Assets.xcassets/mine.imageset/mine@3x.png
--------------------------------------------------------------------------------
/WRNavigationBar_swift/WRNavigationBar_swift/Assets.xcassets/mineHighlight.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "scale" : "1x"
6 | },
7 | {
8 | "idiom" : "universal",
9 | "filename" : "mineHighlight@2x.png",
10 | "scale" : "2x"
11 | },
12 | {
13 | "idiom" : "universal",
14 | "filename" : "mineHighlight@3x.png",
15 | "scale" : "3x"
16 | }
17 | ],
18 | "info" : {
19 | "version" : 1,
20 | "author" : "xcode"
21 | }
22 | }
--------------------------------------------------------------------------------
/WRNavigationBar_swift/WRNavigationBar_swift/Assets.xcassets/mineHighlight.imageset/mineHighlight@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wangrui460/WRNavigationBar_swift/e9e9bd77d0dc856dd872937351e2024c5407d74f/WRNavigationBar_swift/WRNavigationBar_swift/Assets.xcassets/mineHighlight.imageset/mineHighlight@2x.png
--------------------------------------------------------------------------------
/WRNavigationBar_swift/WRNavigationBar_swift/Assets.xcassets/mineHighlight.imageset/mineHighlight@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wangrui460/WRNavigationBar_swift/e9e9bd77d0dc856dd872937351e2024c5407d74f/WRNavigationBar_swift/WRNavigationBar_swift/Assets.xcassets/mineHighlight.imageset/mineHighlight@3x.png
--------------------------------------------------------------------------------
/WRNavigationBar_swift/WRNavigationBar_swift/Assets.xcassets/mysl.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "filename" : "WechatIMG52.png",
6 | "scale" : "1x"
7 | },
8 | {
9 | "idiom" : "universal",
10 | "scale" : "2x"
11 | },
12 | {
13 | "idiom" : "universal",
14 | "scale" : "3x"
15 | }
16 | ],
17 | "info" : {
18 | "version" : 1,
19 | "author" : "xcode"
20 | }
21 | }
--------------------------------------------------------------------------------
/WRNavigationBar_swift/WRNavigationBar_swift/Assets.xcassets/mysl.imageset/WechatIMG52.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wangrui460/WRNavigationBar_swift/e9e9bd77d0dc856dd872937351e2024c5407d74f/WRNavigationBar_swift/WRNavigationBar_swift/Assets.xcassets/mysl.imageset/WechatIMG52.png
--------------------------------------------------------------------------------
/WRNavigationBar_swift/WRNavigationBar_swift/Assets.xcassets/test.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "filename" : "test.jpg",
6 | "scale" : "1x"
7 | },
8 | {
9 | "idiom" : "universal",
10 | "scale" : "2x"
11 | },
12 | {
13 | "idiom" : "universal",
14 | "scale" : "3x"
15 | }
16 | ],
17 | "info" : {
18 | "version" : 1,
19 | "author" : "xcode"
20 | }
21 | }
--------------------------------------------------------------------------------
/WRNavigationBar_swift/WRNavigationBar_swift/Assets.xcassets/test.imageset/test.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wangrui460/WRNavigationBar_swift/e9e9bd77d0dc856dd872937351e2024c5407d74f/WRNavigationBar_swift/WRNavigationBar_swift/Assets.xcassets/test.imageset/test.jpg
--------------------------------------------------------------------------------
/WRNavigationBar_swift/WRNavigationBar_swift/Assets.xcassets/wbBg.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "filename" : "wbBG.png",
6 | "scale" : "1x"
7 | },
8 | {
9 | "idiom" : "universal",
10 | "scale" : "2x"
11 | },
12 | {
13 | "idiom" : "universal",
14 | "scale" : "3x"
15 | }
16 | ],
17 | "info" : {
18 | "version" : 1,
19 | "author" : "xcode"
20 | }
21 | }
--------------------------------------------------------------------------------
/WRNavigationBar_swift/WRNavigationBar_swift/Assets.xcassets/wbBg.imageset/wbBG.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wangrui460/WRNavigationBar_swift/e9e9bd77d0dc856dd872937351e2024c5407d74f/WRNavigationBar_swift/WRNavigationBar_swift/Assets.xcassets/wbBg.imageset/wbBG.png
--------------------------------------------------------------------------------
/WRNavigationBar_swift/WRNavigationBar_swift/Base.lproj/LaunchScreen.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/WRNavigationBar_swift/WRNavigationBar_swift/Base.lproj/Main.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/WRNavigationBar_swift/WRNavigationBar_swift/Demos/AllTransparent.swift:
--------------------------------------------------------------------------------
1 | //
2 | // WeiBoMineController.swift
3 | // WRNavigationBar_swift
4 | //
5 | // Created by wangrui on 2017/4/19.
6 | // Copyright © 2017年 wangrui. All rights reserved.
7 | //
8 | // Github地址:https://github.com/wangrui460/WRNavigationBar_swift
9 |
10 | import UIKit
11 |
12 | private let IMAGE_HEIGHT:CGFloat = 220
13 | private let NAVBAR_COLORCHANGE_POINT:CGFloat = IMAGE_HEIGHT - CGFloat(kNavBarBottom * 2)
14 |
15 | class AllTransparent: UIViewController
16 | {
17 | lazy var tableView:UITableView = {
18 | let table:UITableView = UITableView(frame: CGRect.init(x: 0, y: 0, width: kScreenWidth, height: self.view.bounds.height), style: .plain)
19 | table.contentInset = UIEdgeInsetsMake(-CGFloat(kNavBarBottom), 0, 0, 0);
20 | table.delegate = self
21 | table.dataSource = self
22 | return table
23 | }()
24 | lazy var topView:UIImageView = {
25 | let imgView = UIImageView(image: UIImage(named: "wbBg"))
26 | imgView.frame = CGRect(x: 0, y: 0, width: kScreenWidth, height: IMAGE_HEIGHT)
27 | imgView.contentMode = UIViewContentMode.scaleAspectFill
28 | imgView.clipsToBounds = true
29 | return imgView
30 | }()
31 |
32 | override func viewDidLoad()
33 | {
34 | super.viewDidLoad()
35 | title = "wangrui460"
36 | view.backgroundColor = UIColor.red
37 | view.addSubview(tableView)
38 | tableView.tableHeaderView = topView
39 | navigationItem.rightBarButtonItem = UIBarButtonItem(title: "··· ", style: .done, target: nil, action: nil)
40 |
41 | // 设置导航栏颜色
42 | navBarBarTintColor = UIColor.init(red: 247/255.0, green: 247/255.0, blue: 247/255.0, alpha: 1.0)
43 |
44 | // 设置初始导航栏透明度
45 | navBarBackgroundAlpha = 0
46 |
47 | // 设置导航栏按钮和标题颜色
48 | navBarTintColor = .white
49 |
50 | // 如果需要隐藏导航栏底部分割线,设置 hideShadowImage 为true
51 | // hideShadowImage = true
52 | }
53 |
54 | deinit {
55 | tableView.delegate = nil
56 | print("FirstVC deinit")
57 | }
58 | }
59 |
60 |
61 | // MARK: - 滑动改变导航栏透明度、标题颜色、左右按钮颜色、状态栏颜色
62 | extension AllTransparent
63 | {
64 | func scrollViewDidScroll(_ scrollView: UIScrollView)
65 | {
66 | let offsetY = scrollView.contentOffset.y
67 | if (offsetY > NAVBAR_COLORCHANGE_POINT)
68 | {
69 | let alpha = (offsetY - NAVBAR_COLORCHANGE_POINT) / CGFloat(kNavBarBottom)
70 | navBarBackgroundAlpha = alpha
71 | navBarTintColor = UIColor.black.withAlphaComponent(alpha)
72 | navBarTitleColor = UIColor.black.withAlphaComponent(alpha)
73 | statusBarStyle = .default
74 | }
75 | else
76 | {
77 | navBarBackgroundAlpha = 0
78 | navBarTintColor = .white
79 | navBarTitleColor = .white
80 | statusBarStyle = .lightContent
81 | }
82 | }
83 | }
84 |
85 |
86 | extension AllTransparent:UITableViewDelegate,UITableViewDataSource
87 | {
88 | func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
89 | return 40
90 | }
91 |
92 | func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell
93 | {
94 | let cell = UITableViewCell.init(style: .default, reuseIdentifier: nil)
95 | let str = String(format: "WRNavigationBar %zd", indexPath.row)
96 | cell.textLabel?.text = str
97 | cell.textLabel?.font = UIFont.systemFont(ofSize: 15)
98 | return cell
99 | }
100 |
101 | func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath)
102 | {
103 | tableView.deselectRow(at: indexPath, animated: true)
104 | let vc:AllTransparent = AllTransparent()
105 | navigationController?.pushViewController(vc, animated: true)
106 | }
107 | }
108 |
--------------------------------------------------------------------------------
/WRNavigationBar_swift/WRNavigationBar_swift/Demos/AntForestController.swift:
--------------------------------------------------------------------------------
1 | //
2 | // FourthViewController.swift
3 | // WRNavigationBar_swift
4 | //
5 | // Created by wangrui on 2017/4/21.
6 | // Copyright © 2017年 wangrui. All rights reserved.
7 | //
8 | // Github地址:https://github.com/wangrui460/WRNavigationBar_swift
9 |
10 | import UIKit
11 |
12 | private let NAVBAR_COLORCHANGE_POINT:CGFloat = -480
13 | private let IMAGE_HEIGHT:CGFloat = 480
14 | private let SCROLL_DOWN_LIMIT:CGFloat = 0
15 | private let LIMIT_OFFSET_Y:CGFloat = -(IMAGE_HEIGHT + SCROLL_DOWN_LIMIT)
16 |
17 | class AntForestController: UIViewController
18 | {
19 | lazy var tableView:UITableView = {
20 | let table:UITableView = UITableView(frame: CGRect.init(x: 0, y: 0, width: kScreenWidth, height: self.view.bounds.height), style: .plain)
21 | table.contentInset = UIEdgeInsetsMake(IMAGE_HEIGHT-CGFloat(kNavBarBottom), 0, 0, 0);
22 | table.delegate = self
23 | table.dataSource = self
24 | return table
25 | }()
26 | lazy var imageView:UIImageView = {
27 | let imgView = UIImageView(frame: CGRect(x: 0, y: -IMAGE_HEIGHT, width: kScreenWidth, height: IMAGE_HEIGHT))
28 | imgView.contentMode = UIViewContentMode.scaleAspectFill
29 | imgView.clipsToBounds = true
30 | imgView.image = UIImage(named: "mysl")
31 | return imgView
32 | }()
33 |
34 | override func viewDidLoad()
35 | {
36 | super.viewDidLoad()
37 | title = "蚂蚁森林"
38 | view.backgroundColor = UIColor.red
39 | tableView.addSubview(imageView)
40 | view.addSubview(tableView)
41 | navigationItem.rightBarButtonItem = UIBarButtonItem(title: "··· ", style: .done, target: nil, action: nil)
42 |
43 |
44 | navBarBarTintColor = .white
45 | navBarBackgroundAlpha = 0
46 | }
47 |
48 | deinit {
49 | tableView.delegate = nil
50 | print("FourthVC deinit")
51 | }
52 | }
53 |
54 | // MARK: - viewWillAppear .. ScrollViewDidScroll
55 | extension AntForestController
56 | {
57 | func scrollViewDidScroll(_ scrollView: UIScrollView)
58 | {
59 | let offsetY = scrollView.contentOffset.y
60 | if (offsetY > NAVBAR_COLORCHANGE_POINT)
61 | {
62 | let alpha = (offsetY - NAVBAR_COLORCHANGE_POINT) / CGFloat(kNavBarBottom)
63 | navBarBackgroundAlpha = alpha
64 | if (alpha > 0.5) {
65 | navBarTintColor = UIColor(red: 0, green: 0.478431, blue: 1, alpha: 1.0)
66 | navBarTitleColor = .black
67 | statusBarStyle = .default
68 | } else {
69 | navBarTintColor = .white
70 | navBarTitleColor = .white
71 | statusBarStyle = .lightContent
72 | }
73 | }
74 | else
75 | {
76 | navBarBackgroundAlpha = 0
77 | navBarTintColor = .white
78 | navBarTitleColor = .white
79 | statusBarStyle = .lightContent
80 | }
81 |
82 |
83 |
84 |
85 | // 限制下拉距离
86 | if (offsetY < LIMIT_OFFSET_Y) {
87 | scrollView.contentOffset = CGPoint.init(x: 0, y: LIMIT_OFFSET_Y)
88 | }
89 |
90 | // 改变图片框的大小 (上滑的时候不改变)
91 | // 这里不能使用offsetY,因为当(offsetY < LIMIT_OFFSET_Y)的时候,y = LIMIT_OFFSET_Y 不等于 offsetY
92 | let newOffsetY = scrollView.contentOffset.y
93 | if (newOffsetY < -IMAGE_HEIGHT)
94 | {
95 | imageView.frame = CGRect(x: 0, y: newOffsetY, width: kScreenWidth, height: -newOffsetY)
96 | }
97 | }
98 | }
99 |
100 |
101 | extension AntForestController: UITableViewDelegate,UITableViewDataSource
102 | {
103 | func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
104 | return 25
105 | }
106 |
107 | func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell
108 | {
109 | let cell = UITableViewCell.init(style: .default, reuseIdentifier: nil)
110 | let str = String(format: "WRNavigationBar %zd", indexPath.row)
111 | cell.textLabel?.text = str
112 | cell.textLabel?.font = UIFont.systemFont(ofSize: 15)
113 | return cell
114 | }
115 |
116 | func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath)
117 | {
118 | tableView.deselectRow(at: indexPath, animated: true)
119 | let vc:UIViewController = UIViewController()
120 | vc.view.backgroundColor = UIColor.white
121 | let str = String(format: "WRNavigationBar %zd", indexPath.row)
122 | vc.title = str
123 | navigationController?.pushViewController(vc, animated: true)
124 | }
125 | }
126 |
--------------------------------------------------------------------------------
/WRNavigationBar_swift/WRNavigationBar_swift/Demos/BaseNavigationController.swift:
--------------------------------------------------------------------------------
1 | //
2 | // BaseNavigationController.swift
3 | // WRNavigationBar_swift
4 | //
5 | // Created by wangrui on 2017/4/19.
6 | // Copyright © 2017年 wangrui. All rights reserved.
7 | //
8 | // Github地址:https://github.com/wangrui460/WRNavigationBar_swift
9 |
10 | import UIKit
11 |
12 | class BaseNavigationController: UINavigationController {
13 |
14 | override func viewDidLoad() {
15 | super.viewDidLoad()
16 | }
17 | }
18 |
19 | extension BaseNavigationController
20 | {
21 | override func pushViewController(_ viewController: UIViewController, animated: Bool)
22 | {
23 | if childViewControllers.count > 0 {
24 | viewController.hidesBottomBarWhenPushed = true
25 | }
26 | super.pushViewController(viewController, animated: animated)
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/WRNavigationBar_swift/WRNavigationBar_swift/Demos/BaseViewController.swift:
--------------------------------------------------------------------------------
1 | //
2 | // BaseViewController.swift
3 | // WRNavigationBar_swift
4 | //
5 | // Created by wangrui on 2017/5/16.
6 | // Copyright © 2017年 wangrui. All rights reserved.
7 | //
8 | // Github地址:https://github.com/wangrui460/WRNavigationBar_swift
9 |
10 | import UIKit
11 |
12 | class BaseViewController: UIViewController
13 | {
14 | lazy var navBar = WRCustomNavigationBar.CustomNavigationBar()
15 |
16 | override func viewDidLoad()
17 | {
18 | super.viewDidLoad()
19 | navigationController?.navigationBar.isHidden = true
20 | automaticallyAdjustsScrollViewInsets = false
21 | setupNavBar()
22 |
23 | }
24 |
25 | fileprivate func setupNavBar()
26 | {
27 |
28 | view.addSubview(navBar)
29 |
30 | // 设置自定义导航栏背景图片
31 | navBar.barBackgroundImage = UIImage(named: "millcolorGrad")
32 |
33 | // 设置自定义导航栏背景颜色
34 | // navBar.backgroundColor = MainNavBarColor
35 |
36 | // 设置自定义导航栏标题颜色
37 | navBar.titleLabelColor = .white
38 |
39 | // 设置自定义导航栏左右按钮字体颜色
40 | navBar.wr_setTintColor(color: .white)
41 |
42 | if self.navigationController?.childViewControllers.count != 1 {
43 | navBar.wr_setLeftButton(title: "<<", titleColor: UIColor.white)
44 | }
45 | }
46 |
47 | @objc fileprivate func back()
48 | {
49 | _ = navigationController?.popViewController(animated: true)
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/WRNavigationBar_swift/WRNavigationBar_swift/Demos/CustomListController.swift:
--------------------------------------------------------------------------------
1 | //
2 | // CustomListController.swift
3 | // WRNavigationBar_swift
4 | //
5 | // Created by wangrui on 2017/4/19.
6 | // Copyright © 2017年 wangrui. All rights reserved.
7 | //
8 | // Github地址:https://github.com/wangrui460/WRNavigationBar_swift
9 |
10 | import UIKit
11 |
12 |
13 | class CustomListController: BaseViewController
14 | {
15 | lazy var tableView:UITableView = UITableView(frame: CGRect.init(x: 0, y: CGFloat(kNavBarBottom), width: kScreenWidth, height: self.view.bounds.height), style: .plain)
16 |
17 | override func viewDidLoad()
18 | {
19 | super.viewDidLoad()
20 | view.backgroundColor = UIColor.white
21 | view.addSubview(tableView)
22 | tableView.dataSource = self
23 | tableView.delegate = self
24 | tableView.backgroundColor = UIColor.white
25 | if #available(iOS 11.0, *) {
26 | tableView.contentInsetAdjustmentBehavior = .never
27 | }
28 | view.insertSubview(navBar, aboveSubview: tableView)
29 | navBar.title = "自定义导航栏"
30 | }
31 | }
32 |
33 | // MARK: - tableView delegate / dataSource
34 | extension CustomListController: UITableViewDelegate, UITableViewDataSource
35 | {
36 | func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int
37 | {
38 | return 10
39 | }
40 |
41 | func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell
42 | {
43 | let cell = UITableViewCell.init(style: .default, reuseIdentifier: nil)
44 | var str:String? = nil
45 | switch indexPath.row {
46 | case 0:
47 | str = "主页"
48 | case 1:
49 | str = "导航栏显示图片"
50 | case 2:
51 | str = "实现导航栏渐变色的另一种方式"
52 | default:
53 | str = ""
54 | }
55 | cell.textLabel?.text = str
56 | cell.textLabel?.font = UIFont.systemFont(ofSize: 15)
57 | return cell
58 | }
59 |
60 | func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
61 | return 60
62 | }
63 |
64 | func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath)
65 | {
66 | tableView.deselectRow(at: indexPath, animated: true)
67 | switch indexPath.row {
68 | case 0:
69 | navigationController?.pushViewController(CustomNavBarController(), animated: true)
70 | case 1:
71 | navigationController?.pushViewController(ImageNavController(), animated: true)
72 | case 2:
73 | navigationController?.pushViewController(MillcolorGradController(), animated: true)
74 | default:
75 | break
76 | }
77 | }
78 | }
79 |
80 |
81 |
82 |
83 |
--------------------------------------------------------------------------------
/WRNavigationBar_swift/WRNavigationBar_swift/Demos/CustomNavBarController.swift:
--------------------------------------------------------------------------------
1 | //
2 | // FirstViewController.swift
3 | // WRNavigationBar_swift
4 | //
5 | // Created by wangrui on 2017/4/19.
6 | // Copyright © 2017年 wangrui. All rights reserved.
7 | //
8 | // Github地址:https://github.com/wangrui460/WRNavigationBar_swift
9 |
10 | import UIKit
11 |
12 | private let IMAGE_HEIGHT:CGFloat = 260
13 | private let NAVBAR_COLORCHANGE_POINT:CGFloat = IMAGE_HEIGHT - CGFloat(kNavBarBottom * 2)
14 |
15 | class CustomNavBarController: BaseViewController
16 | {
17 | lazy var tableView:UITableView = {
18 | let frame = CGRect(x: 0, y: 0, width: kScreenWidth, height: self.view.bounds.height)
19 | let table:UITableView = UITableView(frame: frame, style: .plain)
20 | table.contentInset = UIEdgeInsetsMake(0, 0, 0, 0);
21 | table.delegate = self
22 | table.dataSource = self
23 | return table
24 | }()
25 | lazy var imageView:UIImageView = {
26 | let imgView = UIImageView(image: UIImage(named: "image4"))
27 | imgView.frame.size = CGSize(width: 100, height: 100)
28 | imgView.layer.cornerRadius = 50
29 | imgView.layer.masksToBounds = true
30 | return imgView
31 | }()
32 | lazy var topView:UIView = {
33 | let view = UIView(frame: CGRect(x: 0, y: 0, width: kScreenWidth, height: IMAGE_HEIGHT))
34 | view.backgroundColor = UIColor.orange
35 | return view
36 | }()
37 |
38 | override func viewDidLoad()
39 | {
40 | super.viewDidLoad()
41 | view.backgroundColor = UIColor.red
42 | view.addSubview(tableView)
43 | topView.addSubview(imageView)
44 | imageView.center = topView.center
45 | tableView.tableHeaderView = topView
46 | if #available(iOS 11.0, *) {
47 | tableView.contentInsetAdjustmentBehavior = .never
48 | }
49 | view.insertSubview(navBar, aboveSubview: tableView)
50 |
51 | navBar.title = "个人中心"
52 |
53 | // 设置导航栏颜色
54 | navBar.barBackgroundColor = UIColor(red: 247/255.0, green: 247/255.0, blue: 247/255.0, alpha: 1.0)
55 |
56 | // 设置初始导航栏透明度
57 | navBar.wr_setBackgroundAlpha(alpha: 0)
58 |
59 | // 设置标题文字颜色
60 | navBar.titleLabelColor = UIColor.white
61 | }
62 | }
63 |
64 |
65 | // MARK: - ScrollViewDidScroll
66 | extension CustomNavBarController
67 | {
68 | func scrollViewDidScroll(_ scrollView: UIScrollView)
69 | {
70 | let offsetY = scrollView.contentOffset.y
71 | if (offsetY > NAVBAR_COLORCHANGE_POINT)
72 | {
73 | let alpha = (offsetY - NAVBAR_COLORCHANGE_POINT) / CGFloat(kNavBarBottom)
74 | navBar.wr_setBackgroundAlpha(alpha: alpha)
75 | navBar.wr_setTintColor(color: UIColor.black.withAlphaComponent(alpha))
76 | navBar.titleLabelColor = UIColor.black.withAlphaComponent(alpha)
77 | statusBarStyle = .default
78 | }
79 | else
80 | {
81 | navBar.wr_setBackgroundAlpha(alpha: 0)
82 | navBar.wr_setTintColor(color: .white)
83 | navBar.titleLabelColor = .white
84 | statusBarStyle = .lightContent
85 | }
86 | }
87 | }
88 |
89 |
90 | extension CustomNavBarController:UITableViewDelegate,UITableViewDataSource
91 | {
92 | func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
93 | return 15
94 | }
95 |
96 | func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell
97 | {
98 | let cell = UITableViewCell.init(style: .default, reuseIdentifier: nil)
99 | let str = String(format: "WRNavigationBar %zd", indexPath.row)
100 | cell.textLabel?.text = str
101 | cell.textLabel?.font = UIFont.systemFont(ofSize: 15)
102 | return cell
103 | }
104 |
105 | func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath)
106 | {
107 | tableView.deselectRow(at: indexPath, animated: true)
108 | let vc:BaseViewController = BaseViewController()
109 | vc.view.backgroundColor = UIColor.red
110 | let str = String(format: "右滑返回查看效果 ", indexPath.row)
111 | vc.navBar.title = str
112 | navigationController?.pushViewController(vc, animated: true)
113 | }
114 | }
115 |
--------------------------------------------------------------------------------
/WRNavigationBar_swift/WRNavigationBar_swift/Demos/ImageNavController.swift:
--------------------------------------------------------------------------------
1 | //
2 | // ImageNavController .swift
3 | // WRNavigationBar_swift
4 | //
5 | // Created by wangrui on 2017/4/19.
6 | // Copyright © 2017年 wangrui. All rights reserved.
7 | //
8 | // Github地址:https://github.com/wangrui460/WRNavigationBar_swift
9 |
10 | import UIKit
11 |
12 | private let IMAGE_HEIGHT:CGFloat = 220
13 | private let NAVBAR_COLORCHANGE_POINT:CGFloat = IMAGE_HEIGHT - CGFloat(kNavBarBottom * 2)
14 |
15 | class ImageNavController: BaseViewController
16 | {
17 | lazy var tableView:UITableView = {
18 | let table:UITableView = UITableView(frame: CGRect.init(x: 0, y: 0, width: kScreenWidth, height: self.view.bounds.height), style: .plain)
19 | table.contentInset = UIEdgeInsetsMake(0, 0, 0, 0);
20 | table.delegate = self
21 | table.dataSource = self
22 | return table
23 | }()
24 | lazy var topView:UIImageView = {
25 | let imgView = UIImageView(image: UIImage(named: "image7"))
26 | imgView.frame = CGRect(x: 0, y: 0, width: kScreenWidth, height: IMAGE_HEIGHT)
27 | imgView.contentMode = UIViewContentMode.scaleAspectFill
28 | imgView.clipsToBounds = true
29 | return imgView
30 | }()
31 |
32 | override func viewDidLoad()
33 | {
34 | super.viewDidLoad()
35 | navBar.title = "玛丽莲·梦露"
36 | view.backgroundColor = UIColor.red
37 | view.addSubview(tableView)
38 | tableView.tableHeaderView = topView
39 | if #available(iOS 11.0, *) {
40 | tableView.contentInsetAdjustmentBehavior = .never
41 | }
42 | view.insertSubview(navBar, aboveSubview: tableView)
43 |
44 | // 设置导航栏显示图片
45 | navBar.barBackgroundImage = UIImage(named: "imageNav")
46 |
47 | // 设置初始导航栏透明度
48 | navBar.wr_setBackgroundAlpha(alpha: 0)
49 |
50 | // 设置导航栏按钮和标题颜色
51 | navBar.wr_setTintColor(color: .white)
52 |
53 | // 设置状态栏style
54 | statusBarStyle = .lightContent
55 | }
56 |
57 | deinit {
58 | tableView.delegate = nil
59 | print("FirstVC deinit")
60 | }
61 | }
62 |
63 |
64 | // MARK: - 滑动改变导航栏透明度、标题颜色、左右按钮颜色、状态栏颜色
65 | extension ImageNavController
66 | {
67 | func scrollViewDidScroll(_ scrollView: UIScrollView)
68 | {
69 | let offsetY = scrollView.contentOffset.y
70 | if (offsetY > NAVBAR_COLORCHANGE_POINT)
71 | {
72 | let alpha = (offsetY - NAVBAR_COLORCHANGE_POINT) / CGFloat(kNavBarBottom)
73 | navBar.wr_setBackgroundAlpha(alpha: alpha)
74 | }
75 | else
76 | {
77 | navBar.wr_setBackgroundAlpha(alpha: 0)
78 | }
79 | }
80 | }
81 |
82 |
83 | extension ImageNavController:UITableViewDelegate,UITableViewDataSource
84 | {
85 | func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
86 | return 40
87 | }
88 |
89 | func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell
90 | {
91 | let cell = UITableViewCell.init(style: .default, reuseIdentifier: nil)
92 | let str = String(format: "WRNavigationBar %zd", indexPath.row)
93 | cell.textLabel?.text = str
94 | cell.textLabel?.font = UIFont.systemFont(ofSize: 15)
95 | return cell
96 | }
97 |
98 | func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath)
99 | {
100 | tableView.deselectRow(at: indexPath, animated: true)
101 | let vc:BaseViewController = BaseViewController()
102 | vc.view.backgroundColor = UIColor.red
103 | let str = String(format: "右滑返回查看效果 ", indexPath.row)
104 | vc.navBar.title = str
105 | navigationController?.pushViewController(vc, animated: true)
106 | }
107 | }
108 |
--------------------------------------------------------------------------------
/WRNavigationBar_swift/WRNavigationBar_swift/Demos/MillcolorGradController.swift:
--------------------------------------------------------------------------------
1 | //
2 | // ImageNavController .swift
3 | // WRNavigationBar_swift
4 | //
5 | // Created by wangrui on 2017/4/19.
6 | // Copyright © 2017年 wangrui. All rights reserved.
7 | //
8 | // Github地址:https://github.com/wangrui460/WRNavigationBar_swift
9 |
10 | import UIKit
11 |
12 | private let IMAGE_HEIGHT:CGFloat = 250
13 | private let NAVBAR_COLORCHANGE_POINT:CGFloat = IMAGE_HEIGHT - CGFloat(kNavBarBottom * 2)
14 |
15 | class MillcolorGradController: BaseViewController
16 | {
17 | lazy var tableView:UITableView = {
18 | let table:UITableView = UITableView(frame: CGRect.init(x: 0, y: 0, width: kScreenWidth, height: self.view.bounds.height), style: .plain)
19 | table.contentInset = UIEdgeInsetsMake(0, 0, 0, 0);
20 | table.delegate = self
21 | table.dataSource = self
22 | return table
23 | }()
24 | lazy var topView:UIImageView = {
25 | let imgView = UIImageView(image: UIImage(named: "image8"))
26 | imgView.frame = CGRect(x: 0, y: 0, width: kScreenWidth, height: IMAGE_HEIGHT)
27 | imgView.contentMode = UIViewContentMode.scaleAspectFill
28 | imgView.clipsToBounds = true
29 | return imgView
30 | }()
31 |
32 | override func viewDidLoad()
33 | {
34 | super.viewDidLoad()
35 | navBar.title = "奥黛丽·赫本"
36 | view.backgroundColor = UIColor.red
37 | view.addSubview(tableView)
38 | tableView.tableHeaderView = topView
39 | if #available(iOS 11.0, *) {
40 | tableView.contentInsetAdjustmentBehavior = .never
41 | }
42 | view.insertSubview(navBar, aboveSubview: tableView)
43 |
44 | // 设置初始导航栏透明度
45 | navBar.wr_setBackgroundAlpha(alpha: 0)
46 |
47 | // 设置导航栏按钮和标题颜色
48 | navBar.wr_setTintColor(color: .white)
49 |
50 | // 设置状态栏style
51 | statusBarStyle = .lightContent
52 | }
53 |
54 | deinit {
55 | tableView.delegate = nil
56 | print("FirstVC deinit")
57 | }
58 | }
59 |
60 |
61 | // MARK: - 滑动改变导航栏透明度、标题颜色、左右按钮颜色、状态栏颜色
62 | extension MillcolorGradController
63 | {
64 | func scrollViewDidScroll(_ scrollView: UIScrollView)
65 | {
66 | let offsetY = scrollView.contentOffset.y
67 | if (offsetY > NAVBAR_COLORCHANGE_POINT)
68 | {
69 | let alpha = (offsetY - NAVBAR_COLORCHANGE_POINT) / CGFloat(kNavBarBottom)
70 | navBar.wr_setBackgroundAlpha(alpha: alpha)
71 | }
72 | else
73 | {
74 | navBar.wr_setBackgroundAlpha(alpha: 0)
75 | }
76 | }
77 | }
78 |
79 |
80 | extension MillcolorGradController:UITableViewDelegate,UITableViewDataSource
81 | {
82 | func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
83 | return 40
84 | }
85 |
86 | func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell
87 | {
88 | let cell = UITableViewCell.init(style: .default, reuseIdentifier: nil)
89 | let str = String(format: "WRNavigationBar %zd", indexPath.row)
90 | cell.textLabel?.text = str
91 | cell.textLabel?.font = UIFont.systemFont(ofSize: 15)
92 | return cell
93 | }
94 |
95 | func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath)
96 | {
97 | tableView.deselectRow(at: indexPath, animated: true)
98 | let vc:BaseViewController = BaseViewController()
99 | vc.view.backgroundColor = UIColor.red
100 | let str = String(format: "右滑返回查看效果 ", indexPath.row)
101 | vc.navBar.title = str
102 | navigationController?.pushViewController(vc, animated: true)
103 | }
104 | }
105 |
--------------------------------------------------------------------------------
/WRNavigationBar_swift/WRNavigationBar_swift/Demos/MoveListController.swift:
--------------------------------------------------------------------------------
1 | //
2 | // MoveListController.swift
3 | // WRNavigationBar_swift
4 | //
5 | // Created by wangrui on 2017/4/19.
6 | // Copyright © 2017年 wangrui. All rights reserved.
7 | //
8 | // Github地址:https://github.com/wangrui460/WRNavigationBar_swift
9 |
10 | import UIKit
11 |
12 |
13 | class MoveListController: UIViewController
14 | {
15 | lazy var tableView:UITableView = UITableView(frame: CGRect.init(x: 0, y: 0, width: kScreenWidth, height: self.view.bounds.height), style: .plain)
16 |
17 | override func viewDidLoad() {
18 | super.viewDidLoad()
19 | view.backgroundColor = UIColor.white
20 | title = "移动导航栏"
21 | view.addSubview(tableView)
22 | tableView.dataSource = self
23 | tableView.delegate = self
24 | // tableView.backgroundColor = UIColor.init(red: 254/255.0, green: 128/255.0, blue: 162/255.0, alpha: 1.0)
25 | tableView.backgroundColor = UIColor.white
26 |
27 | navBarBarTintColor = UIColor.init(red: 247/255.0, green: 247/255.0, blue: 247/255.0, alpha: 1.0)
28 | navBarBackgroundAlpha = 1.0
29 | navBarTintColor = .black
30 | navBarTitleColor = .black
31 | statusBarStyle = .default
32 | }
33 | }
34 |
35 | // MARK: - tableView delegate / dataSource
36 | extension MoveListController: UITableViewDelegate, UITableViewDataSource
37 | {
38 | func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int
39 | {
40 | return 10
41 | }
42 |
43 | func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell
44 | {
45 | let cell = UITableViewCell.init(style: .default, reuseIdentifier: nil)
46 | var str:String? = nil
47 | switch indexPath.row {
48 | case 0:
49 | str = "超过临界点移动导航栏";
50 | case 1:
51 | str = "没有系统返回按钮的情况";
52 | default:
53 | str = ""
54 | }
55 | cell.textLabel?.text = str
56 | cell.textLabel?.font = UIFont.systemFont(ofSize: 15)
57 | return cell
58 | }
59 |
60 | func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
61 | return 60
62 | }
63 |
64 | func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath)
65 | {
66 | tableView.deselectRow(at: indexPath, animated: true)
67 | switch indexPath.row {
68 | case 0:
69 | navigationController?.pushViewController(SecondViewController(), animated: true)
70 | case 1:
71 | navigationController?.pushViewController(SixthViewController(), animated: true)
72 | default:
73 | break
74 | }
75 | }
76 | }
77 |
78 |
79 |
80 |
81 |
--------------------------------------------------------------------------------
/WRNavigationBar_swift/WRNavigationBar_swift/Demos/NormalListController.swift:
--------------------------------------------------------------------------------
1 | //
2 | // NormalListController.swift
3 | // WRNavigationBar_swift
4 | //
5 | // Created by wangrui on 2017/4/19.
6 | // Copyright © 2017年 wangrui. All rights reserved.
7 | //
8 | // Github地址:https://github.com/wangrui460/WRNavigationBar_swift
9 |
10 | import UIKit
11 |
12 | let kNavBarBottom = WRNavigationBar.navBarBottom()
13 |
14 | class NormalListController: UIViewController
15 | {
16 | lazy var tableView:UITableView = UITableView(frame: CGRect.init(x: 0, y: 0, width: kScreenWidth, height: self.view.bounds.height), style: .plain)
17 |
18 | override func viewDidLoad() {
19 | super.viewDidLoad()
20 | view.backgroundColor = UIColor.white
21 | title = "常用"
22 | view.addSubview(tableView)
23 | tableView.dataSource = self
24 | tableView.delegate = self
25 | tableView.backgroundColor = UIColor.white
26 |
27 | // 改变标题文字大小
28 | // navigationController?.navigationBar.titleTextAttributes = [NSFontAttributeName:UIFont.systemFont(ofSize: 22)]
29 | }
30 | }
31 |
32 |
33 |
34 | // MARK: - tableView delegate / dataSource
35 | extension NormalListController: UITableViewDelegate, UITableViewDataSource
36 | {
37 | func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int
38 | {
39 | return 10
40 | }
41 |
42 | func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell
43 | {
44 | let cell = UITableViewCell.init(style: .default, reuseIdentifier: nil)
45 | var str:String? = nil
46 | switch indexPath.row {
47 | case 0:
48 | str = "新浪微博个人中心"
49 | case 1:
50 | str = "类似qq应用空间效果"
51 | case 2:
52 | str = "类似QQ空间效果"
53 | case 3:
54 | str = "知乎日报"
55 | case 4:
56 | str = "QQ我的资料页"
57 | case 5:
58 | str = "蚂蚁森林"
59 | case 6:
60 | str = "连续多个界面导航栏透明"
61 | default:
62 | str = ""
63 | }
64 | cell.textLabel?.text = str
65 | cell.textLabel?.font = UIFont.systemFont(ofSize: 15)
66 | return cell
67 | }
68 |
69 | func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
70 | return 60
71 | }
72 |
73 | func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath)
74 | {
75 | tableView.deselectRow(at: indexPath, animated: true)
76 | switch indexPath.row {
77 | case 0:
78 | navigationController?.pushViewController(WeiBoMineController(), animated: true)
79 | case 1:
80 | navigationController?.pushViewController(QQAppController(), animated: true)
81 | case 2:
82 | navigationController?.pushViewController(QQZoneController(), animated: true)
83 | case 3:
84 | navigationController?.pushViewController(ZhiHuController(), animated: true)
85 | case 4:
86 | navigationController?.pushViewController(QQMineController(), animated: true)
87 | case 5:
88 | navigationController?.pushViewController(AntForestController(), animated: true)
89 | case 6:
90 | navigationController?.pushViewController(AllTransparent(), animated: true)
91 | default:
92 | break
93 | }
94 | }
95 | }
96 |
97 |
98 |
99 |
100 |
--------------------------------------------------------------------------------
/WRNavigationBar_swift/WRNavigationBar_swift/Demos/QQAppController.swift:
--------------------------------------------------------------------------------
1 | //
2 | // QQAppController.swift
3 | // WRNavigationBar_swift
4 | //
5 | // Created by wangrui on 2017/4/21.
6 | // Copyright © 2017年 wangrui. All rights reserved.
7 | //
8 | // Github地址:https://github.com/wangrui460/WRNavigationBar_swift
9 |
10 | import UIKit
11 |
12 | private let NAVBAR_COLORCHANGE_POINT:CGFloat = -80
13 | private let IMAGE_HEIGHT:CGFloat = 260
14 | private let SCROLL_DOWN_LIMIT:CGFloat = 100
15 | private let LIMIT_OFFSET_Y:CGFloat = -(IMAGE_HEIGHT + SCROLL_DOWN_LIMIT)
16 |
17 | class QQAppController: UIViewController
18 | {
19 | lazy var tableView:UITableView = {
20 | let table:UITableView = UITableView(frame: CGRect.init(x: 0, y: 0, width: kScreenWidth, height: self.view.bounds.height), style: .plain)
21 | table.contentInset = UIEdgeInsetsMake(IMAGE_HEIGHT-CGFloat(kNavBarBottom), 0, 0, 0);
22 | table.delegate = self
23 | table.dataSource = self
24 | return table
25 | }()
26 | lazy var imageView:UIImageView = {
27 | let imgView = UIImageView(frame: CGRect(x: 0, y: -IMAGE_HEIGHT, width: kScreenWidth, height: IMAGE_HEIGHT))
28 | imgView.contentMode = UIViewContentMode.scaleAspectFill
29 | imgView.clipsToBounds = true
30 | imgView.image = self.imageScaledToSize(image: UIImage(named: "image3")!, newSize: CGSize(width: kScreenWidth, height: IMAGE_HEIGHT+SCROLL_DOWN_LIMIT))
31 | return imgView
32 | }()
33 |
34 | override func viewDidLoad()
35 | {
36 | super.viewDidLoad()
37 | title = "qq应用"
38 | view.backgroundColor = UIColor.red
39 | tableView.addSubview(imageView)
40 | view.addSubview(tableView)
41 |
42 | navBarBackgroundAlpha = 0
43 | }
44 |
45 | deinit {
46 | tableView.delegate = nil
47 | print("FourthVC deinit")
48 | }
49 | }
50 |
51 | // MARK: - viewWillAppear .. ScrollViewDidScroll
52 | extension QQAppController
53 | {
54 | func scrollViewDidScroll(_ scrollView: UIScrollView)
55 | {
56 | let offsetY = scrollView.contentOffset.y
57 |
58 | if (offsetY > NAVBAR_COLORCHANGE_POINT) {
59 | changeNavBarAnimateWithIsClear(isClear: false)
60 | } else {
61 | changeNavBarAnimateWithIsClear(isClear: true)
62 | }
63 |
64 | // 限制下拉距离
65 | if (offsetY < LIMIT_OFFSET_Y) {
66 | scrollView.contentOffset = CGPoint.init(x: 0, y: LIMIT_OFFSET_Y)
67 | }
68 |
69 | // 改变图片框的大小 (上滑的时候不改变)
70 | // 这里不能使用offsetY,因为当(offsetY < LIMIT_OFFSET_Y)的时候,y = LIMIT_OFFSET_Y 不等于 offsetY
71 | let newOffsetY = scrollView.contentOffset.y
72 | if (newOffsetY < -IMAGE_HEIGHT)
73 | {
74 | imageView.frame = CGRect(x: 0, y: newOffsetY, width: kScreenWidth, height: -newOffsetY)
75 | }
76 | }
77 |
78 | // private
79 | private func changeNavBarAnimateWithIsClear(isClear:Bool)
80 | {
81 | UIView.animate(withDuration: 0.8, animations: { [weak self] in
82 | if let weakSelf = self
83 | {
84 | if (isClear == true) {
85 | weakSelf.navBarBackgroundAlpha = 0
86 | }
87 | else {
88 | weakSelf.navBarBackgroundAlpha = 1.0
89 | }
90 | }
91 | })
92 | }
93 |
94 | // private
95 | fileprivate func imageScaledToSize(image:UIImage, newSize:CGSize) -> UIImage
96 | {
97 | UIGraphicsBeginImageContext(CGSize(width: newSize.width * 2.0, height: newSize.height * 2.0))
98 | image.draw(in: CGRect(x: 0, y: 0, width: newSize.width * 2.0, height: newSize.height * 2.0))
99 | let newImage:UIImage = UIGraphicsGetImageFromCurrentImageContext() ?? image
100 | UIGraphicsEndImageContext()
101 | return newImage
102 | }
103 | }
104 |
105 |
106 | extension QQAppController: UITableViewDelegate,UITableViewDataSource
107 | {
108 | func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
109 | return 25
110 | }
111 |
112 | func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell
113 | {
114 | let cell = UITableViewCell.init(style: .default, reuseIdentifier: nil)
115 | let str = String(format: "WRNavigationBar %zd", indexPath.row)
116 | cell.textLabel?.text = str
117 | cell.textLabel?.font = UIFont.systemFont(ofSize: 15)
118 | return cell
119 | }
120 |
121 | func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath)
122 | {
123 | tableView.deselectRow(at: indexPath, animated: true)
124 | let vc:UIViewController = UIViewController()
125 | vc.view.backgroundColor = UIColor.white
126 | let str = String(format: "WRNavigationBar %zd", indexPath.row)
127 | vc.title = str
128 | navigationController?.pushViewController(vc, animated: true)
129 | }
130 | }
131 |
--------------------------------------------------------------------------------
/WRNavigationBar_swift/WRNavigationBar_swift/Demos/QQMineController.swift:
--------------------------------------------------------------------------------
1 | //
2 | // FirstViewController.swift
3 | // WRNavigationBar_swift
4 | //
5 | // Created by wangrui on 2017/4/19.
6 | // Copyright © 2017年 wangrui. All rights reserved.
7 | //
8 | // Github地址:https://github.com/wangrui460/WRNavigationBar_swift
9 |
10 | import UIKit
11 |
12 | private let IMAGE_HEIGHT:CGFloat = 280
13 | private let NAVBAR_COLORCHANGE_POINT:CGFloat = IMAGE_HEIGHT - CGFloat(kNavBarBottom)
14 |
15 | class QQMineController: UIViewController
16 | {
17 | lazy var tableView:UITableView = {
18 | let table:UITableView = UITableView(frame: CGRect.init(x: 0, y: 0, width: kScreenWidth, height: self.view.bounds.height), style: .plain)
19 | table.backgroundColor = UIColor.clear
20 | table.contentInset = UIEdgeInsetsMake(-CGFloat(kNavBarBottom), 0, 0, 0);
21 | table.delegate = self
22 | table.dataSource = self
23 | return table
24 | }()
25 | lazy var bottomImgView:UIImageView = {
26 | let imgView = UIImageView(image: UIImage(named: "bottomImage"))
27 | imgView.frame.size = CGSize(width: kScreenWidth, height: kScreenHeight)
28 | return imgView
29 | }()
30 | lazy var nameLabel:UILabel = {
31 | let label = UILabel()
32 | label.backgroundColor = UIColor.clear
33 | label.textColor = UIColor.white
34 | label.text = "wangrui460"
35 | label.textAlignment = .center
36 | label.font = .systemFont(ofSize: 20)
37 | return label
38 | }()
39 | lazy var imageView:UIImageView = {
40 | let imgView = UIImageView(image: UIImage(named: "image4"))
41 | imgView.frame.size = CGSize(width: 90, height: 90)
42 | imgView.layer.borderColor = UIColor.white.cgColor
43 | imgView.layer.borderWidth = 2
44 | imgView.layer.cornerRadius = 45
45 | imgView.layer.masksToBounds = true
46 | return imgView
47 | }()
48 | lazy var topView:UIView = {
49 | let view = UIView(frame: CGRect(x: 0, y: CGFloat(kNavBarBottom), width: kScreenWidth, height: IMAGE_HEIGHT))
50 | view.backgroundColor = UIColor.clear
51 | return view
52 | }()
53 |
54 | override func viewDidLoad()
55 | {
56 | super.viewDidLoad()
57 | automaticallyAdjustsScrollViewInsets = false
58 | title = ""
59 | navigationItem.rightBarButtonItem = UIBarButtonItem(title: "编辑", style: .plain, target: self, action: nil)
60 | view.backgroundColor = UIColor.red
61 | view.addSubview(bottomImgView)
62 | view.addSubview(tableView)
63 | topView.addSubview(imageView)
64 | imageView.center = CGPoint(x: topView.center.x, y: topView.center.y - 20)
65 | topView.addSubview(nameLabel)
66 | nameLabel.frame = CGRect(x: 0, y: imageView.frame.size.height+imageView.frame.origin.y+10, width: kScreenWidth, height: 25)
67 | tableView.tableHeaderView = topView
68 |
69 | // 设置导航栏颜色
70 | navBarBarTintColor = MainNavBarColor
71 |
72 | // 设置初始导航栏透明度
73 | navBarBackgroundAlpha = 0
74 |
75 | // 设置导航栏按钮和标题颜色
76 | navBarTintColor = .white
77 | }
78 |
79 | deinit {
80 | tableView.delegate = nil
81 | print("QQMineVC deinit")
82 | }
83 | }
84 |
85 |
86 | // MARK: - 滑动改变导航栏透明度
87 | extension QQMineController
88 | {
89 | func scrollViewDidScroll(_ scrollView: UIScrollView)
90 | {
91 | let offsetY = scrollView.contentOffset.y
92 | if (offsetY > NAVBAR_COLORCHANGE_POINT)
93 | {
94 | changeNavBarAnimateWithIsClear(isClear: false)
95 | title = "wangrui460"
96 | }
97 | else
98 | {
99 | changeNavBarAnimateWithIsClear(isClear: true)
100 | title = ""
101 | }
102 | }
103 |
104 | // private
105 | private func changeNavBarAnimateWithIsClear(isClear:Bool)
106 | {
107 | UIView.animate(withDuration: 0.5, animations: { [weak self] in
108 | if let weakSelf = self
109 | {
110 | if (isClear == true) {
111 | weakSelf.navBarBackgroundAlpha = 0
112 | }
113 | else {
114 | weakSelf.navBarBackgroundAlpha = 1.0
115 | }
116 | }
117 | })
118 | }
119 | }
120 |
121 |
122 | extension QQMineController:UITableViewDelegate,UITableViewDataSource
123 | {
124 | func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
125 | return 25
126 | }
127 |
128 | func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell
129 | {
130 | let cell = UITableViewCell.init(style: .default, reuseIdentifier: nil)
131 | let str = String(format: "WRNavigationBar %zd", indexPath.row)
132 | cell.textLabel?.text = str
133 | cell.textLabel?.font = UIFont.systemFont(ofSize: 15)
134 | cell.backgroundColor = UIColor.black.withAlphaComponent(0.5)
135 | cell.textLabel?.textColor = UIColor.white
136 | cell.accessoryType = .disclosureIndicator
137 | return cell
138 | }
139 |
140 | func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath)
141 | {
142 | tableView.deselectRow(at: indexPath, animated: true)
143 | let vc:UIViewController = UIViewController()
144 | vc.view.backgroundColor = UIColor.white
145 | let str = "WRNavigationBar"
146 | vc.title = str
147 | navigationController?.pushViewController(vc, animated: true)
148 | }
149 | }
150 |
--------------------------------------------------------------------------------
/WRNavigationBar_swift/WRNavigationBar_swift/Demos/QQZoneController.swift:
--------------------------------------------------------------------------------
1 | //
2 | // QQZoneController.swift
3 | // WRNavigationBar_swift
4 | //
5 | // Created by wangrui on 2017/4/21.
6 | // Copyright © 2017年 wangrui. All rights reserved.
7 | //
8 | // Github地址:https://github.com/wangrui460/WRNavigationBar_swift
9 |
10 | import UIKit
11 |
12 | private let NAVBAR_COLORCHANGE_POINT:CGFloat = (-IMAGE_HEIGHT + CGFloat(kNavBarBottom * 2))
13 | private let IMAGE_HEIGHT:CGFloat = 260
14 | private let SCROLL_DOWN_LIMIT:CGFloat = 100
15 | private let LIMIT_OFFSET_Y:CGFloat = -(IMAGE_HEIGHT + SCROLL_DOWN_LIMIT)
16 |
17 | class QQZoneController: UIViewController
18 | {
19 | lazy var tableView:UITableView = {
20 | let table:UITableView = UITableView(frame: CGRect.init(x: 0, y: 0, width: kScreenWidth, height: self.view.bounds.height), style: .plain)
21 | table.contentInset = UIEdgeInsetsMake(IMAGE_HEIGHT-CGFloat(kNavBarBottom), 0, 0, 0);
22 | table.delegate = self
23 | table.dataSource = self
24 | return table
25 | }()
26 | lazy var imageView:UIImageView = {
27 | let imgView = UIImageView(frame: CGRect(x: 0, y: -IMAGE_HEIGHT, width: kScreenWidth, height: IMAGE_HEIGHT))
28 | imgView.contentMode = UIViewContentMode.scaleAspectFill
29 | imgView.clipsToBounds = true
30 | imgView.image = self.imageScaledToSize(image: UIImage(named: "image6")!, newSize: CGSize(width: kScreenWidth, height: IMAGE_HEIGHT+SCROLL_DOWN_LIMIT))
31 | return imgView
32 | }()
33 |
34 | override func viewDidLoad()
35 | {
36 | super.viewDidLoad()
37 | title = "qq空间"
38 | view.backgroundColor = UIColor.red
39 | tableView.addSubview(imageView)
40 | view.addSubview(tableView)
41 |
42 | navBarBackgroundAlpha = 0
43 | }
44 |
45 | deinit {
46 | tableView.delegate = nil
47 | print("FifthVC deinit")
48 | }
49 | }
50 |
51 |
52 | // MARK: - viewWillAppear .. ScrollViewDidScroll
53 | extension QQZoneController
54 | {
55 | func scrollViewDidScroll(_ scrollView: UIScrollView)
56 | {
57 | let offsetY = scrollView.contentOffset.y
58 |
59 | if (offsetY > NAVBAR_COLORCHANGE_POINT)
60 | {
61 | let alpha = (offsetY - NAVBAR_COLORCHANGE_POINT) / CGFloat(kNavBarBottom)
62 | navBarBackgroundAlpha = alpha
63 | }
64 | else
65 | {
66 | navBarBackgroundAlpha = 0
67 | }
68 |
69 | // 限制下拉距离
70 | if (offsetY < LIMIT_OFFSET_Y) {
71 | scrollView.contentOffset = CGPoint.init(x: 0, y: LIMIT_OFFSET_Y)
72 | }
73 |
74 | // 改变图片框的大小 (上滑的时候不改变)
75 | // 这里不能使用offsetY,因为当(offsetY < LIMIT_OFFSET_Y)的时候,y = LIMIT_OFFSET_Y 不等于 offsetY
76 | let newOffsetY = scrollView.contentOffset.y
77 | if (newOffsetY < -IMAGE_HEIGHT)
78 | {
79 | imageView.frame = CGRect(x: 0, y: newOffsetY, width: kScreenWidth, height: -newOffsetY)
80 | }
81 | }
82 |
83 | // private
84 | fileprivate func imageScaledToSize(image:UIImage, newSize:CGSize) -> UIImage
85 | {
86 | UIGraphicsBeginImageContext(CGSize(width: newSize.width * 2.0, height: newSize.height * 2.0))
87 | image.draw(in: CGRect(x: 0, y: 0, width: newSize.width * 2.0, height: newSize.height * 2.0))
88 | let newImage:UIImage = UIGraphicsGetImageFromCurrentImageContext() ?? image
89 | UIGraphicsEndImageContext()
90 | return newImage
91 | }
92 | }
93 |
94 |
95 | extension QQZoneController: UITableViewDelegate,UITableViewDataSource
96 | {
97 | func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
98 | return 15
99 | }
100 |
101 | func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell
102 | {
103 | let cell = UITableViewCell.init(style: .default, reuseIdentifier: nil)
104 | let str = String(format: "WRNavigationBar %zd", indexPath.row)
105 | cell.textLabel?.text = str
106 | cell.textLabel?.font = UIFont.systemFont(ofSize: 15)
107 | return cell
108 | }
109 |
110 | func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath)
111 | {
112 | tableView.deselectRow(at: indexPath, animated: true)
113 | let vc:UIViewController = UIViewController()
114 | vc.view.backgroundColor = UIColor.gray
115 | let str = String(format: "WRNavigationBar %zd", indexPath.row)
116 | vc.title = str
117 | navigationController?.pushViewController(vc, animated: true)
118 | }
119 | }
120 |
--------------------------------------------------------------------------------
/WRNavigationBar_swift/WRNavigationBar_swift/Demos/SecondViewController.swift:
--------------------------------------------------------------------------------
1 | //
2 | // SecondViewController.swift
3 | // WRNavigationBar_swift
4 | //
5 | // Created by wangrui on 2017/4/21.
6 | // Copyright © 2017年 wangrui. All rights reserved.
7 | //
8 | // Github地址:https://github.com/wangrui460/WRNavigationBar_swift
9 |
10 | import UIKit
11 |
12 | private let NAVBAR_TRANSLATION_POINT:CGFloat = 0
13 |
14 | class SecondViewController: UIViewController
15 | {
16 | lazy var tableView:UITableView = {
17 | let table:UITableView = UITableView(frame: CGRect.init(x: 0, y: 0, width: kScreenWidth, height: self.view.bounds.height), style: .plain)
18 | table.contentInset = UIEdgeInsetsMake(-CGFloat(kNavBarBottom), 0, 0, 0);
19 | table.delegate = self
20 | table.dataSource = self
21 | return table
22 | }()
23 | lazy var imageView:UIImageView = {
24 | let imgView = UIImageView(image: UIImage(named: "image2"))
25 | return imgView
26 | }()
27 |
28 | override func viewDidLoad()
29 | {
30 | super.viewDidLoad()
31 | title = "浮动效果"
32 | view.backgroundColor = UIColor.red
33 | view.addSubview(tableView)
34 | tableView.tableHeaderView = imageView
35 | }
36 |
37 | deinit {
38 | tableView.delegate = nil
39 | print("SecondVC deinit")
40 | }
41 | }
42 |
43 |
44 | // MARK: - viewWillAppear .. ScrollViewDidScroll
45 | extension SecondViewController
46 | {
47 | override func viewDidAppear(_ animated: Bool)
48 | {
49 | super.viewDidAppear(animated)
50 | tableView.delegate = self;
51 | }
52 |
53 | override func viewWillDisappear(_ animated: Bool)
54 | {
55 | super.viewWillDisappear(animated)
56 | tableView.delegate = nil
57 | navigationController?.navigationBar.wr_setTranslationY(translationY: 0)
58 | }
59 |
60 | func scrollViewDidScroll(_ scrollView: UIScrollView)
61 | {
62 | let offsetY = scrollView.contentOffset.y
63 | if (offsetY > NAVBAR_TRANSLATION_POINT)
64 | {
65 | UIView.animate(withDuration: 0.3, animations: { [weak self] in
66 | if let weakSelf = self {
67 | weakSelf.setNavigationBarTransformProgress(progress: 1)
68 | }
69 | })
70 | }
71 | else
72 | {
73 | UIView.animate(withDuration: 0.3, animations: { [weak self] in
74 | if let weakSelf = self {
75 | weakSelf.setNavigationBarTransformProgress(progress: 0)
76 | }
77 | })
78 | }
79 | }
80 |
81 | // private
82 | func setNavigationBarTransformProgress(progress:CGFloat)
83 | {
84 | navigationController?.navigationBar.wr_setTranslationY(translationY: -CGFloat(kNavBarHeight) * progress)
85 | // 有系统的返回按钮,所以 hasSystemBackIndicator = YES
86 | navigationController?.navigationBar.wr_setBarButtonItemsAlpha(alpha: 1 - progress, hasSystemBackIndicator: true)
87 | }
88 | }
89 |
90 |
91 | extension SecondViewController:UITableViewDelegate,UITableViewDataSource
92 | {
93 | func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
94 | return 15
95 | }
96 |
97 | func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell
98 | {
99 | let cell = UITableViewCell.init(style: .default, reuseIdentifier: nil)
100 | let str = String(format: "WRNavigationBar %zd", indexPath.row)
101 | cell.textLabel?.text = str
102 | cell.textLabel?.font = UIFont.systemFont(ofSize: 15)
103 | return cell
104 | }
105 |
106 | func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath)
107 | {
108 | tableView.deselectRow(at: indexPath, animated: true)
109 | let vc:UIViewController = UIViewController()
110 | vc.view.backgroundColor = UIColor.red
111 | let str = String(format: "WRNavigationBar %zd", indexPath.row)
112 | vc.title = str
113 | navigationController?.pushViewController(vc, animated: true)
114 | }
115 | }
116 |
--------------------------------------------------------------------------------
/WRNavigationBar_swift/WRNavigationBar_swift/Demos/SixthViewController.swift:
--------------------------------------------------------------------------------
1 | //
2 | // SixthViewController.swift
3 | // WRNavigationBar_swift
4 | //
5 | // Created by wangrui on 2017/4/19.
6 | // Copyright © 2017年 wangrui. All rights reserved.
7 | //
8 | // Github地址:https://github.com/wangrui460/WRNavigationBar_swift
9 |
10 | import UIKit
11 |
12 | private let NAVBAR_TRANSLATION_POINT:CGFloat = 0
13 |
14 | class SixthViewController: UIViewController
15 | {
16 | lazy var tableView:UITableView = {
17 | let table:UITableView = UITableView(frame: CGRect.init(x: 0, y: 0, width: kScreenWidth, height: self.view.bounds.height), style: .plain)
18 | table.contentInset = UIEdgeInsetsMake(-CGFloat(kNavBarBottom), 0, 0, 0);
19 | table.delegate = self
20 | table.dataSource = self
21 | return table
22 | }()
23 | lazy var imageView:UIImageView = {
24 | let imgView = UIImageView(image: UIImage(named: "image2"))
25 | return imgView
26 | }()
27 |
28 | override func viewDidLoad()
29 | {
30 | super.viewDidLoad()
31 | title = "看90行代码"
32 | view.backgroundColor = UIColor.red
33 | view.addSubview(tableView)
34 | tableView.tableHeaderView = imageView
35 | self.navigationItem.leftBarButtonItem = UIBarButtonItem(title: "自定义返回", style: .done, target: self, action: #selector(back))
36 | }
37 |
38 | @objc func back() {
39 | _ = self.navigationController?.popViewController(animated: true)
40 | }
41 |
42 | deinit {
43 | tableView.delegate = nil
44 | print("SixthVC deinit")
45 | }
46 | }
47 |
48 |
49 | // MARK: - viewWillAppear .. ScrollViewDidScroll
50 | extension SixthViewController
51 | {
52 | override func viewDidAppear(_ animated: Bool)
53 | {
54 | super.viewDidAppear(animated)
55 | tableView.delegate = self;
56 | }
57 |
58 | override func viewWillDisappear(_ animated: Bool)
59 | {
60 | super.viewWillDisappear(animated)
61 | tableView.delegate = nil
62 | navigationController?.navigationBar.wr_setTranslationY(translationY: 0)
63 | }
64 |
65 | func scrollViewDidScroll(_ scrollView: UIScrollView)
66 | {
67 | let offsetY = scrollView.contentOffset.y
68 | // 向上滑动的距离
69 | let scrollUpHeight = offsetY - NAVBAR_TRANSLATION_POINT
70 | // 除数表示 -> 导航栏从完全不透明到完全透明的过渡距离
71 | let progress = scrollUpHeight / CGFloat(kNavBarHeight)
72 | if (offsetY > NAVBAR_TRANSLATION_POINT)
73 | {
74 | if (scrollUpHeight > CGFloat(kNavBarHeight)) {
75 | setNavigationBarTransformProgress(progress: 1)
76 | }
77 | else {
78 | setNavigationBarTransformProgress(progress: progress)
79 | }
80 | }
81 | else
82 | {
83 | self.setNavigationBarTransformProgress(progress: 0)
84 | }
85 | }
86 |
87 | // private
88 | func setNavigationBarTransformProgress(progress:CGFloat)
89 | {
90 | navigationController?.navigationBar.wr_setTranslationY(translationY: -CGFloat(kNavBarHeight) * progress)
91 | // 没有系统返回按钮,所以 hasSystemBackIndicator = false
92 | // 如果这里不设置为false,你会发现,导航栏无缘无故多出来一个返回按钮
93 | navigationController?.navigationBar.wr_setBarButtonItemsAlpha(alpha: 1 - progress, hasSystemBackIndicator: false)
94 | }
95 | }
96 |
97 |
98 | extension SixthViewController: UITableViewDelegate,UITableViewDataSource
99 | {
100 | func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
101 | return 15
102 | }
103 |
104 | func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell
105 | {
106 | let cell = UITableViewCell.init(style: .default, reuseIdentifier: nil)
107 | let str = String(format: "WRNavigationBar %zd", indexPath.row)
108 | cell.textLabel?.text = str
109 | cell.textLabel?.font = UIFont.systemFont(ofSize: 15)
110 | return cell
111 | }
112 |
113 | func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath)
114 | {
115 | tableView.deselectRow(at: indexPath, animated: true)
116 |
117 | // 做成这种样式,最好不要有点击事件
118 | }
119 | }
120 |
--------------------------------------------------------------------------------
/WRNavigationBar_swift/WRNavigationBar_swift/Demos/WeiBoMineController.swift:
--------------------------------------------------------------------------------
1 | //
2 | // WeiBoMineController.swift
3 | // WRNavigationBar_swift
4 | //
5 | // Created by wangrui on 2017/4/19.
6 | // Copyright © 2017年 wangrui. All rights reserved.
7 | //
8 | // Github地址:https://github.com/wangrui460/WRNavigationBar_swift
9 |
10 | import UIKit
11 |
12 | private let IMAGE_HEIGHT:CGFloat = 220
13 | private let NAVBAR_COLORCHANGE_POINT:CGFloat = IMAGE_HEIGHT - CGFloat(kNavBarBottom * 2)
14 |
15 | class WeiBoMineController: UIViewController
16 | {
17 | lazy var tableView:UITableView = {
18 | let table:UITableView = UITableView(frame: CGRect.init(x: 0, y: 0, width: kScreenWidth, height: self.view.bounds.height), style: .plain)
19 | table.contentInset = UIEdgeInsetsMake(-CGFloat(kNavBarBottom), 0, 0, 0);
20 | table.delegate = self
21 | table.dataSource = self
22 | return table
23 | }()
24 | lazy var iconView:UIImageView = {
25 | let imgView = UIImageView(image: UIImage(named: "image5"))
26 | imgView.frame.size = CGSize(width: 80, height: 80)
27 | imgView.layer.borderColor = UIColor.white.cgColor
28 | imgView.layer.borderWidth = 2
29 | imgView.layer.cornerRadius = 40
30 | imgView.layer.masksToBounds = true
31 | return imgView
32 | }()
33 | lazy var nameLabel:UILabel = {
34 | let label = UILabel()
35 | label.backgroundColor = UIColor.clear
36 | label.textColor = UIColor.white
37 | label.text = "wangrui460"
38 | label.textAlignment = .center
39 | label.font = .systemFont(ofSize: 17)
40 | return label
41 | }()
42 | lazy var fansLabel:UILabel = {
43 | let label = UILabel()
44 | label.backgroundColor = UIColor.clear
45 | label.textColor = UIColor.white
46 | label.text = "关注 121 | 粉丝 891"
47 | label.textAlignment = .center
48 | label.font = .boldSystemFont(ofSize: 14)
49 | return label
50 | }()
51 | lazy var detailLabel:UILabel = {
52 | let label = UILabel()
53 | label.backgroundColor = UIColor.clear
54 | label.textColor = UIColor.white
55 | label.text = "简介:丽人丽妆公司,熊猫美妆APP iOS工程师"
56 | label.textAlignment = .center
57 | label.font = .systemFont(ofSize: 13)
58 | return label
59 | }()
60 | lazy var topView:UIImageView = {
61 | let imgView = UIImageView(image: UIImage(named: "wbBg"))
62 | imgView.frame = CGRect(x: 0, y: 0, width: kScreenWidth, height: IMAGE_HEIGHT)
63 | imgView.contentMode = UIViewContentMode.scaleAspectFill
64 | imgView.clipsToBounds = true
65 | return imgView
66 | }()
67 |
68 | override func viewDidLoad()
69 | {
70 | super.viewDidLoad()
71 | title = ""
72 | view.backgroundColor = UIColor.red
73 | view.addSubview(tableView)
74 | topView.addSubview(iconView)
75 | iconView.center = CGPoint(x: topView.center.x, y: topView.center.y - 10)
76 | topView.addSubview(nameLabel)
77 | nameLabel.frame = CGRect(x: 0, y: iconView.frame.size.height+iconView.frame.origin.y+6, width: kScreenWidth, height: 19)
78 | topView.addSubview(fansLabel)
79 | fansLabel.frame = CGRect(x: 0, y: nameLabel.frame.origin.y+19+5, width: kScreenWidth, height: 16)
80 | topView.addSubview(detailLabel)
81 | detailLabel.frame = CGRect(x: 0, y: fansLabel.frame.origin.y+16+5, width: kScreenWidth, height: 15)
82 | tableView.tableHeaderView = topView
83 | navigationItem.rightBarButtonItem = UIBarButtonItem(title: "··· ", style: .done, target: nil, action: nil)
84 |
85 | // 设置导航栏颜色
86 | navBarBarTintColor = UIColor.init(red: 247/255.0, green: 247/255.0, blue: 247/255.0, alpha: 1.0)
87 |
88 | // 设置初始导航栏透明度
89 | navBarBackgroundAlpha = 0
90 |
91 | // 设置导航栏按钮和标题颜色
92 | navBarTintColor = .white
93 |
94 | // 如果需要隐藏导航栏底部分割线,设置 hideShadowImage 为true
95 | // hideShadowImage = true
96 | }
97 |
98 | deinit {
99 | tableView.delegate = nil
100 | print("FirstVC deinit")
101 | }
102 | }
103 |
104 |
105 | // MARK: - 滑动改变导航栏透明度、标题颜色、左右按钮颜色、状态栏颜色
106 | extension WeiBoMineController
107 | {
108 | func scrollViewDidScroll(_ scrollView: UIScrollView)
109 | {
110 | let offsetY = scrollView.contentOffset.y
111 | if (offsetY > NAVBAR_COLORCHANGE_POINT)
112 | {
113 | let alpha = (offsetY - NAVBAR_COLORCHANGE_POINT) / CGFloat(kNavBarBottom)
114 | navBarBackgroundAlpha = alpha
115 | navBarTintColor = UIColor.black.withAlphaComponent(alpha)
116 | navBarTitleColor = UIColor.black.withAlphaComponent(alpha)
117 | statusBarStyle = .default
118 | title = "wangrui460"
119 | }
120 | else
121 | {
122 | navBarBackgroundAlpha = 0
123 | navBarTintColor = .white
124 | navBarTitleColor = .white
125 | statusBarStyle = .lightContent
126 | title = ""
127 | }
128 | }
129 | }
130 |
131 |
132 | extension WeiBoMineController:UITableViewDelegate,UITableViewDataSource
133 | {
134 | func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
135 | return 40
136 | }
137 |
138 | func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell
139 | {
140 | let cell = UITableViewCell.init(style: .default, reuseIdentifier: nil)
141 | let str = String(format: "WRNavigationBar %zd", indexPath.row)
142 | cell.textLabel?.text = str
143 | cell.textLabel?.font = UIFont.systemFont(ofSize: 15)
144 | return cell
145 | }
146 |
147 | func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath)
148 | {
149 | tableView.deselectRow(at: indexPath, animated: true)
150 | let vc:UIViewController = UIViewController()
151 | vc.view.backgroundColor = UIColor.white
152 | let str = "WRNavigationBar"
153 | vc.title = str
154 | navigationController?.pushViewController(vc, animated: true)
155 | }
156 | }
157 |
--------------------------------------------------------------------------------
/WRNavigationBar_swift/WRNavigationBar_swift/Demos/ZhiHuController.swift:
--------------------------------------------------------------------------------
1 | //
2 | // ZhiHuController.swift
3 | // ZhihuDaily-Swift3.0
4 | //
5 | // Created by wangrui on 2017/5/5.
6 | // Copyright © 2017年 wangrui. All rights reserved.
7 | //
8 | // Github地址:https://github.com/wangrui460/WRNavigationBar_swift
9 |
10 | import UIKit
11 |
12 | private let NAVBAR_COLORCHANGE_POINT:CGFloat = -80
13 | private let IMAGE_HEIGHT:CGFloat = 240
14 | private let SCROLL_DOWN_LIMIT:CGFloat = 100
15 | private let LIMIT_OFFSET_Y:CGFloat = -(IMAGE_HEIGHT + SCROLL_DOWN_LIMIT)
16 |
17 | class ZhiHuController: UIViewController
18 | {
19 | lazy var tableView:UITableView = {
20 | let table:UITableView = UITableView(frame: CGRect.init(x: 0, y: 0, width: Int(kScreenWidth), height: Int(self.view.bounds.height)), style: .plain)
21 | table.contentInset = UIEdgeInsetsMake(IMAGE_HEIGHT-CGFloat(kNavBarBottom), 0, 0, 0);
22 | table.showsVerticalScrollIndicator = false
23 | table.delegate = self
24 | table.dataSource = self
25 | return table
26 | }()
27 | lazy var cycleScrollView:WRCycleScrollView = {
28 | let frame = CGRect(x: 0, y: -IMAGE_HEIGHT, width: CGFloat(kScreenWidth), height: IMAGE_HEIGHT)
29 | let cycleView = WRCycleScrollView(frame: frame, type: .LOCAL, imgs: nil, descs: nil)
30 | return cycleView
31 | }()
32 |
33 | override func viewDidLoad()
34 | {
35 | super.viewDidLoad()
36 | self.title = "知乎日报"
37 | view.backgroundColor = UIColor.white
38 | let localImages = ["localImg6","localImg7","localImg8","localImg9","localImg10"]
39 | let descs = ["韩国防部回应停止部署萨德:遵照最高统帅指导方针",
40 | "勒索病毒攻击再次爆发 国内校园网大面积感染",
41 | "Win10秋季更新重磅功能:跟安卓与iOS无缝连接",
42 | "《琅琊榜2》为何没有胡歌?胡歌:我看过剧本,离开是种保护",
43 | "阿米尔汗在印度的影响力,我国的哪位影视明星能与之齐名呢?"]
44 | cycleScrollView.localImgArray = localImages
45 | cycleScrollView.descTextArray = descs
46 | tableView.addSubview(cycleScrollView)
47 | view.addSubview(tableView)
48 |
49 | navBarBarTintColor = MainNavBarColor
50 | navBarBackgroundAlpha = 0
51 | navBarTintColor = .white
52 | }
53 |
54 | deinit {
55 | tableView.delegate = nil
56 | print("ZhiHuVC deinit")
57 | }
58 | }
59 |
60 | // MARK: - ScrollViewDidScroll
61 | extension ZhiHuController
62 | {
63 | func scrollViewDidScroll(_ scrollView: UIScrollView)
64 | {
65 | let offsetY = scrollView.contentOffset.y
66 |
67 | if (offsetY > NAVBAR_COLORCHANGE_POINT)
68 | {
69 | let alpha = (offsetY - NAVBAR_COLORCHANGE_POINT) / CGFloat(kNavBarBottom)
70 | navBarBackgroundAlpha = alpha
71 | }
72 | else
73 | {
74 | navBarBackgroundAlpha = 0
75 | }
76 |
77 | // 限制下拉距离
78 | if (offsetY < LIMIT_OFFSET_Y) {
79 | scrollView.contentOffset = CGPoint.init(x: 0, y: LIMIT_OFFSET_Y)
80 | }
81 |
82 | // 改变图片框的大小 (上滑的时候不改变)
83 | // 这里不能使用offsetY,因为当(offsetY < LIMIT_OFFSET_Y)的时候,y = LIMIT_OFFSET_Y 不等于 offsetY
84 | let newOffsetY = scrollView.contentOffset.y
85 | if (newOffsetY < -IMAGE_HEIGHT)
86 | {
87 | cycleScrollView.frame = CGRect(x: 0, y: newOffsetY, width: CGFloat(kScreenWidth), height: -newOffsetY)
88 | }
89 | }
90 |
91 | // private
92 | fileprivate func imageScaledToSize(image:UIImage, newSize:CGSize) -> UIImage
93 | {
94 | UIGraphicsBeginImageContext(CGSize(width: newSize.width * 2.0, height: newSize.height * 2.0))
95 | image.draw(in: CGRect(x: 0, y: 0, width: newSize.width * 2.0, height: newSize.height * 2.0))
96 | let newImage:UIImage = UIGraphicsGetImageFromCurrentImageContext() ?? image
97 | UIGraphicsEndImageContext()
98 | return newImage
99 | }
100 | }
101 |
102 | extension ZhiHuController: UITableViewDelegate,UITableViewDataSource
103 | {
104 | func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
105 | return 25
106 | }
107 |
108 | func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell
109 | {
110 | let cell = UITableViewCell.init(style: .default, reuseIdentifier: nil)
111 | let str = String(format: "知乎日报 %zd", indexPath.row)
112 | cell.textLabel?.text = str
113 | cell.textLabel?.font = UIFont.systemFont(ofSize: 15)
114 | return cell
115 | }
116 |
117 | func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath)
118 | {
119 | tableView.deselectRow(at: indexPath, animated: true)
120 | let vc:UIViewController = UIViewController()
121 | vc.view.backgroundColor = UIColor.red
122 | let str = String(format: "知乎日报 %zd", indexPath.row)
123 | vc.title = str
124 | navigationController?.pushViewController(vc, animated: true)
125 | }
126 | }
127 |
128 |
129 |
130 |
--------------------------------------------------------------------------------
/WRNavigationBar_swift/WRNavigationBar_swift/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIcons
10 |
11 | CFBundleIcons~ipad
12 |
13 | CFBundleIdentifier
14 | $(PRODUCT_BUNDLE_IDENTIFIER)
15 | CFBundleInfoDictionaryVersion
16 | 6.0
17 | CFBundleName
18 | $(PRODUCT_NAME)
19 | CFBundlePackageType
20 | APPL
21 | CFBundleShortVersionString
22 | 1.0
23 | CFBundleVersion
24 | 1
25 | LSRequiresIPhoneOS
26 |
27 | UILaunchStoryboardName
28 | LaunchScreen
29 | UIRequiredDeviceCapabilities
30 |
31 | armv7
32 |
33 | UISupportedInterfaceOrientations
34 |
35 | UIInterfaceOrientationPortrait
36 | UIInterfaceOrientationLandscapeLeft
37 | UIInterfaceOrientationLandscapeRight
38 |
39 | UISupportedInterfaceOrientations~ipad
40 |
41 | UIInterfaceOrientationPortrait
42 | UIInterfaceOrientationPortraitUpsideDown
43 | UIInterfaceOrientationLandscapeLeft
44 | UIInterfaceOrientationLandscapeRight
45 |
46 |
47 |
48 |
--------------------------------------------------------------------------------
/WRNavigationBar_swift/WRNavigationBar_swift/WRNavigationBar/WRCustomNavigationBar.swift:
--------------------------------------------------------------------------------
1 | //
2 | // WRCustomNavigationBar.swift
3 | // WRNavigationBar_swift
4 | //
5 | // Created by itwangrui on 2017/11/25.
6 | // Copyright © 2017年 wangrui. All rights reserved.
7 | //
8 |
9 | import UIKit
10 |
11 | fileprivate let WRDefaultTitleSize:CGFloat = 18
12 | fileprivate let WRDefaultTitleColor = UIColor.black
13 | fileprivate let WRDefaultBackgroundColor = UIColor.white
14 | fileprivate let WRScreenWidth = UIScreen.main.bounds.size.width
15 |
16 |
17 | // MARK: - Router
18 | extension UIViewController
19 | {
20 | // A页面 弹出 登录页面B
21 | // presentedViewController: A页面
22 | // presentingViewController: B页面
23 |
24 | func wr_toLastViewController(animated:Bool)
25 | {
26 | if self.navigationController != nil
27 | {
28 | if self.navigationController?.viewControllers.count == 1
29 | {
30 | self.dismiss(animated: animated, completion: nil)
31 | } else {
32 | self.navigationController?.popViewController(animated: animated)
33 | }
34 | }
35 | else if self.presentingViewController != nil {
36 | self.dismiss(animated: animated, completion: nil)
37 | }
38 | }
39 |
40 | class func wr_currentViewController() -> UIViewController
41 | {
42 | if let rootVC = UIApplication.shared.delegate?.window??.rootViewController {
43 | return self.wr_currentViewController(from: rootVC)
44 | } else {
45 | return UIViewController()
46 | }
47 | }
48 |
49 | class func wr_currentViewController(from fromVC:UIViewController) -> UIViewController
50 | {
51 | if fromVC.isKind(of: UINavigationController.self) {
52 | let navigationController = fromVC as! UINavigationController
53 | return wr_currentViewController(from: navigationController.viewControllers.last!)
54 | }
55 | else if fromVC.isKind(of: UITabBarController.self) {
56 | let tabBarController = fromVC as! UITabBarController
57 | return wr_currentViewController(from: tabBarController.selectedViewController!)
58 | }
59 | else if fromVC.presentedViewController != nil {
60 | return wr_currentViewController(from:fromVC.presentingViewController!)
61 | }
62 | else {
63 | return fromVC
64 | }
65 | }
66 | }
67 |
68 |
69 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////
70 | class WRCustomNavigationBar: UIView
71 | {
72 | var onClickLeftButton:(()->())?
73 | var onClickRightButton:(()->())?
74 | var title:String? {
75 | willSet {
76 | titleLabel.isHidden = false
77 | titleLabel.text = newValue
78 | }
79 | }
80 | var titleLabelColor:UIColor? {
81 | willSet {
82 | titleLabel.textColor = newValue
83 | }
84 | }
85 | var titleLabelFont:UIFont? {
86 | willSet {
87 | titleLabel.font = newValue
88 | }
89 | }
90 | var barBackgroundColor:UIColor? {
91 | willSet {
92 | backgroundImageView.isHidden = true
93 | backgroundView.isHidden = false
94 | backgroundView.backgroundColor = newValue
95 | }
96 | }
97 | var barBackgroundImage:UIImage? {
98 | willSet {
99 | backgroundView.isHidden = true
100 | backgroundImageView.isHidden = false
101 | backgroundImageView.image = newValue
102 | }
103 | }
104 |
105 | // fileprivate UI variable
106 | fileprivate lazy var titleLabel:UILabel = {
107 | let label = UILabel()
108 | label.textColor = WRDefaultTitleColor
109 | label.font = UIFont.systemFont(ofSize: WRDefaultTitleSize)
110 | label.textAlignment = .center
111 | label.isHidden = true
112 | return label
113 | }()
114 |
115 | fileprivate lazy var leftButton:UIButton = {
116 | let button = UIButton()
117 | button.imageView?.contentMode = .center
118 | button.isHidden = true
119 | button.addTarget(self, action: #selector(clickBack), for: .touchUpInside)
120 | return button
121 | }()
122 |
123 | fileprivate lazy var rightButton:UIButton = {
124 | let button = UIButton()
125 | button.imageView?.contentMode = .center
126 | button.isHidden = true
127 | button.addTarget(self, action: #selector(clickRight), for: .touchUpInside)
128 | return button
129 | }()
130 |
131 | fileprivate lazy var bottomLine:UIView = {
132 | let view = UIView()
133 | view.backgroundColor = UIColor(red: (218.0/255.0), green: (218.0/255.0), blue: (218.0/255.0), alpha: 1.0)
134 | return view
135 | }()
136 |
137 | fileprivate lazy var backgroundView:UIView = {
138 | let view = UIView()
139 | return view
140 | }()
141 |
142 | fileprivate lazy var backgroundImageView:UIImageView = {
143 | let imgView = UIImageView()
144 | imgView.isHidden = true
145 | return imgView
146 | }()
147 |
148 | // fileprivate other variable
149 | fileprivate static var isIphoneX:Bool {
150 | get {
151 | return UIScreen.main.bounds.equalTo(CGRect(x: 0, y: 0, width: 375, height: 812))
152 | }
153 | }
154 | fileprivate static var navBarBottom:Int {
155 | get {
156 | return isIphoneX ? 88 : 64
157 | }
158 | }
159 |
160 | // init
161 | class func CustomNavigationBar() -> WRCustomNavigationBar {
162 | let frame = CGRect(x: 0, y: 0, width: WRScreenWidth, height: CGFloat(navBarBottom))
163 | return WRCustomNavigationBar(frame: frame)
164 | }
165 | override init(frame: CGRect) {
166 | super.init(frame: frame)
167 | setupView()
168 | }
169 | required init?(coder aDecoder: NSCoder) {
170 | super.init(coder: aDecoder)
171 | setupView()
172 | }
173 |
174 | func setupView()
175 | {
176 | addSubview(backgroundView)
177 | addSubview(backgroundImageView)
178 | addSubview(leftButton)
179 | addSubview(titleLabel)
180 | addSubview(rightButton)
181 | addSubview(bottomLine)
182 | updateFrame()
183 | backgroundColor = UIColor.clear
184 | backgroundView.backgroundColor = WRDefaultBackgroundColor
185 | }
186 | func updateFrame()
187 | {
188 | let top:CGFloat = WRCustomNavigationBar.isIphoneX ? 44 : 20
189 | let margin:CGFloat = 0
190 | let buttonHeight:CGFloat = 44
191 | let buttonWidth:CGFloat = 44
192 | let titleLabelHeight:CGFloat = 44
193 | let titleLabelWidth:CGFloat = 180
194 |
195 | backgroundView.frame = self.bounds
196 | backgroundImageView.frame = self.bounds
197 | leftButton.frame = CGRect(x: margin, y: top, width: buttonWidth, height: buttonHeight)
198 | rightButton.frame = CGRect(x: WRScreenWidth-buttonWidth-margin, y: top, width: buttonWidth, height: buttonHeight)
199 | titleLabel.frame = CGRect(x: (WRScreenWidth-titleLabelWidth)/2.0, y: top, width: titleLabelWidth, height: titleLabelHeight)
200 | bottomLine.frame = CGRect(x: 0, y: bounds.height-0.5, width: WRScreenWidth, height: 0.5)
201 | }
202 | }
203 |
204 |
205 | extension WRCustomNavigationBar
206 | {
207 | func wr_setBottomLineHidden(hidden:Bool) {
208 | bottomLine.isHidden = hidden
209 | }
210 | func wr_setBackgroundAlpha(alpha:CGFloat) {
211 | backgroundView.alpha = alpha
212 | backgroundImageView.alpha = alpha
213 | bottomLine.alpha = alpha
214 | }
215 | func wr_setTintColor(color:UIColor) {
216 | leftButton.setTitleColor(color, for: .normal)
217 | rightButton.setTitleColor(color, for: .normal)
218 | titleLabel.textColor = color
219 | }
220 |
221 | // 左右按钮共有方法
222 | func wr_setLeftButton(normal:UIImage, highlighted:UIImage) {
223 | wr_setLeftButton(normal: normal, highlighted: highlighted, title: nil, titleColor: nil)
224 | }
225 | func wr_setLeftButton(image:UIImage) {
226 | wr_setLeftButton(normal: image, highlighted: image, title: nil, titleColor: nil)
227 | }
228 | func wr_setLeftButton(title:String, titleColor:UIColor) {
229 | wr_setLeftButton(normal: nil, highlighted: nil, title: title, titleColor: titleColor)
230 | }
231 |
232 | func wr_setRightButton(normal:UIImage, highlighted:UIImage) {
233 | wr_setRightButton(normal: normal, highlighted: highlighted, title: nil, titleColor: nil)
234 | }
235 | func wr_setRightButton(image:UIImage) {
236 | wr_setRightButton(normal: image, highlighted: image, title: nil, titleColor: nil)
237 | }
238 | func wr_setRightButton(title:String, titleColor:UIColor) {
239 | wr_setRightButton(normal: nil, highlighted: nil, title: title, titleColor: titleColor)
240 | }
241 |
242 |
243 | // 左右按钮私有方法
244 | private func wr_setLeftButton(normal:UIImage?, highlighted:UIImage?, title:String?, titleColor:UIColor?) {
245 | leftButton.isHidden = false
246 | leftButton.setImage(normal, for: .normal)
247 | leftButton.setImage(highlighted, for: .highlighted)
248 | leftButton.setTitle(title, for: .normal)
249 | leftButton.setTitleColor(titleColor, for: .normal)
250 | }
251 | private func wr_setRightButton(normal:UIImage?, highlighted:UIImage?, title:String?, titleColor:UIColor?) {
252 | rightButton.isHidden = false
253 | rightButton.setImage(normal, for: .normal)
254 | rightButton.setImage(highlighted, for: .highlighted)
255 | rightButton.setTitle(title, for: .normal)
256 | rightButton.setTitleColor(titleColor, for: .normal)
257 | }
258 | }
259 |
260 |
261 | // MARK: - 导航栏左右按钮事件
262 | extension WRCustomNavigationBar
263 | {
264 | @objc func clickBack() {
265 | if let onClickBack = onClickLeftButton {
266 | onClickBack()
267 | } else {
268 | let currentVC = UIViewController.wr_currentViewController()
269 | currentVC.wr_toLastViewController(animated: true)
270 | }
271 | }
272 | @objc func clickRight() {
273 | if let onClickRight = onClickRightButton {
274 | onClickRight()
275 | }
276 | }
277 | }
278 |
279 |
280 |
281 |
282 |
283 |
284 |
285 |
286 |
287 |
288 |
289 |
290 |
291 |
292 |
293 |
294 |
295 |
296 |
297 |
298 |
299 |
300 |
301 |
302 |
--------------------------------------------------------------------------------
/WRNavigationBar_swift/WRNavigationBar_swift/WRNavigationBar/WRCycleScrollView/WRCycleCell.swift:
--------------------------------------------------------------------------------
1 | //
2 | // WRCycleCell.swift
3 | // WRCycleScrollViewDemo
4 | //
5 | // Created by wangrui on 2017/5/12.
6 | // Copyright © 2017年 wangrui. All rights reserved.
7 | //
8 | // Github地址:https://github.com/wangrui460/WRCycleScrollView
9 |
10 | import UIKit
11 | import Kingfisher
12 |
13 | class WRCycleCell: UICollectionViewCell
14 | {
15 | //=======================================================
16 | // MARK: 对外提供的属性
17 | //=======================================================
18 | var imgSource:ImgSource = ImgSource.LOCAL(name: "placeholder") {
19 | didSet {
20 | switch imgSource {
21 | case let .SERVER(url):
22 | imgView.kf.setImage(with: url)
23 | case let .LOCAL(name):
24 | imgView.image = UIImage(named: name)
25 | }
26 | }
27 | }
28 |
29 | var descText:String? {
30 | didSet {
31 | descLabel.isHidden = (descText == nil) ? true : false
32 | bottomView.isHidden = (descText == nil) ? true : false
33 | descLabel.text = descText
34 | }
35 | }
36 |
37 | override var frame: CGRect {
38 | didSet {
39 | bounds.size = frame.size
40 | }
41 | }
42 |
43 | var descLabelFont: UIFont = UIFont(name: "Helvetica-Bold", size: 18)! {
44 | didSet {
45 | descLabel.font = descLabelFont
46 | }
47 | }
48 | var descLabelTextColor: UIColor = UIColor.white {
49 | didSet {
50 | descLabel.textColor = descLabelTextColor
51 | }
52 | }
53 | var descLabelHeight: CGFloat = 60 {
54 | didSet {
55 | descLabel.frame.size.height = descLabelHeight
56 | }
57 | }
58 | var descLabelTextAlignment:NSTextAlignment = .left {
59 | didSet {
60 | descLabel.textAlignment = descLabelTextAlignment
61 | }
62 | }
63 | var bottomViewBackgroundColor: UIColor = UIColor.black.withAlphaComponent(0.5) {
64 | didSet {
65 | bottomView.backgroundColor = bottomViewBackgroundColor
66 | }
67 | }
68 |
69 | //=======================================================
70 | // MARK: 内部属性
71 | //=======================================================
72 | fileprivate var imgView:UIImageView!
73 | fileprivate var descLabel:UILabel!
74 | fileprivate var bottomView:UIView!
75 |
76 | //=======================================================
77 | // MARK: 构造方法
78 | //=======================================================
79 | override init(frame: CGRect)
80 | {
81 | super.init(frame: frame)
82 | backgroundColor = UIColor.white
83 | setupImgView()
84 | setupDescLabel()
85 | setupBottomView()
86 | }
87 | required init?(coder aDecoder: NSCoder) {
88 | fatalError("init(coder:) has not been implemented")
89 | }
90 | deinit {
91 | print("WRCycleCell deinit")
92 | }
93 |
94 |
95 | //=======================================================
96 | // MARK: 内部方法(layoutSubviews)
97 | //=======================================================
98 | override func layoutSubviews()
99 | {
100 | super.layoutSubviews()
101 | imgView.frame = self.bounds
102 |
103 | if let _ = descText
104 | {
105 | let margin:CGFloat = 16
106 | let labelWidth = imgView.bounds.width - 2 * margin
107 | let labelHeight = descLabelHeight
108 | let labelY = bounds.height - labelHeight
109 | descLabel.frame = CGRect(x: margin, y: labelY, width: labelWidth, height: labelHeight)
110 | bottomView.frame = CGRect(x: 0, y: labelY, width: imgView.bounds.width, height: labelHeight)
111 | bringSubview(toFront: descLabel)
112 | }
113 | }
114 | }
115 |
116 | //=======================================================
117 | // MARK: - 基本控件(图片、描述文字、底部view)
118 | //=======================================================
119 | extension WRCycleCell
120 | {
121 | fileprivate func setupImgView()
122 | {
123 | imgView = UIImageView()
124 | imgView.contentMode = .scaleAspectFill
125 | imgView.clipsToBounds = true
126 | addSubview(imgView)
127 | }
128 |
129 | fileprivate func setupDescLabel()
130 | {
131 | descLabel = UILabel()
132 | descLabel.text = descText
133 | descLabel.numberOfLines = 0
134 | descLabel.font = descLabelFont
135 | descLabel.textColor = descLabelTextColor
136 | descLabel.frame.size.height = descLabelHeight
137 | descLabel.textAlignment = descLabelTextAlignment
138 | addSubview(descLabel)
139 | descLabel.isHidden = true
140 | }
141 |
142 | fileprivate func setupBottomView()
143 | {
144 | bottomView = UIView()
145 | bottomView.backgroundColor = bottomViewBackgroundColor
146 | addSubview(bottomView)
147 | bottomView.isHidden = true
148 | }
149 | }
150 |
151 |
--------------------------------------------------------------------------------
/WRNavigationBar_swift/WRNavigationBar_swift/WRNavigationBar/WRCycleScrollView/WRProxy.swift:
--------------------------------------------------------------------------------
1 | //
2 | // WRProxy.swift
3 | // WRCycleScrollViewDemo
4 | //
5 | // Created by wangrui on 2017/5/15.
6 | // Copyright © 2017年 wangrui. All rights reserved.
7 | //
8 |
9 | import UIKit
10 |
11 | // 图片资源
12 | enum ImgSource {
13 | case SERVER(url:URL)
14 | case LOCAL(name:String)
15 | }
16 |
17 | // 图片类型
18 | enum ImgType:Int {
19 | case SERVER = 0 // default
20 | case LOCAL = 1
21 | }
22 |
23 | struct Proxy
24 | {
25 | var imgType:ImgType = .SERVER
26 | var imgArray:[ImgSource] = [ImgSource]()
27 |
28 | // 下标法获取imgArray中对应索引的ImgSource
29 | subscript (index:Int) -> ImgSource {
30 | get {
31 | return imgArray[index]
32 | }
33 | }
34 |
35 | // 构造方法
36 | init(type:ImgType, array:[String])
37 | {
38 | imgType = type
39 | if imgType == .SERVER
40 | {
41 | imgArray = array.map({ (urlStr) -> ImgSource in
42 | return ImgSource.SERVER(url: URL(string: urlStr)!)
43 | })
44 | }
45 | else
46 | {
47 | imgArray = array.map({ (name) -> ImgSource in
48 | return ImgSource.LOCAL(name: name)
49 | })
50 | }
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/WRNavigationBar_swift/WRNavigationBar_swiftTests/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | BNDL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleVersion
20 | 1
21 |
22 |
23 |
--------------------------------------------------------------------------------
/WRNavigationBar_swift/WRNavigationBar_swiftTests/WRNavigationBar_swiftTests.swift:
--------------------------------------------------------------------------------
1 | //
2 | // WRNavigationBar_swiftTests.swift
3 | // WRNavigationBar_swiftTests
4 | //
5 | // Created by wangrui on 2017/4/19.
6 | // Copyright © 2017年 wangrui. All rights reserved.
7 | //
8 |
9 | import XCTest
10 | @testable import WRNavigationBar_swift
11 |
12 | class WRNavigationBar_swiftTests: XCTestCase {
13 |
14 | override func setUp() {
15 | super.setUp()
16 | // Put setup code here. This method is called before the invocation of each test method in the class.
17 | }
18 |
19 | override func tearDown() {
20 | // Put teardown code here. This method is called after the invocation of each test method in the class.
21 | super.tearDown()
22 | }
23 |
24 | func testExample() {
25 | // This is an example of a functional test case.
26 | // Use XCTAssert and related functions to verify your tests produce the correct results.
27 | }
28 |
29 | func testPerformanceExample() {
30 | // This is an example of a performance test case.
31 | self.measure {
32 | // Put the code you want to measure the time of here.
33 | }
34 | }
35 |
36 | }
37 |
--------------------------------------------------------------------------------
/screenshots/QQ我的资料页.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wangrui460/WRNavigationBar_swift/e9e9bd77d0dc856dd872937351e2024c5407d74f/screenshots/QQ我的资料页.gif
--------------------------------------------------------------------------------
/screenshots/apps.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wangrui460/WRNavigationBar_swift/e9e9bd77d0dc856dd872937351e2024c5407d74f/screenshots/apps.png
--------------------------------------------------------------------------------
/screenshots/mysl.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wangrui460/WRNavigationBar_swift/e9e9bd77d0dc856dd872937351e2024c5407d74f/screenshots/mysl.gif
--------------------------------------------------------------------------------
/screenshots/mysl滑动.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wangrui460/WRNavigationBar_swift/e9e9bd77d0dc856dd872937351e2024c5407d74f/screenshots/mysl滑动.gif
--------------------------------------------------------------------------------
/screenshots/qq空间.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wangrui460/WRNavigationBar_swift/e9e9bd77d0dc856dd872937351e2024c5407d74f/screenshots/qq空间.gif
--------------------------------------------------------------------------------
/screenshots/处理右滑中断后.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wangrui460/WRNavigationBar_swift/e9e9bd77d0dc856dd872937351e2024c5407d74f/screenshots/处理右滑中断后.gif
--------------------------------------------------------------------------------
/screenshots/处理右滑返回手势后.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wangrui460/WRNavigationBar_swift/e9e9bd77d0dc856dd872937351e2024c5407d74f/screenshots/处理右滑返回手势后.gif
--------------------------------------------------------------------------------
/screenshots/导航栏显示图片.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wangrui460/WRNavigationBar_swift/e9e9bd77d0dc856dd872937351e2024c5407d74f/screenshots/导航栏显示图片.gif
--------------------------------------------------------------------------------
/screenshots/导航栏显示渐变色.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wangrui460/WRNavigationBar_swift/e9e9bd77d0dc856dd872937351e2024c5407d74f/screenshots/导航栏显示渐变色.gif
--------------------------------------------------------------------------------
/screenshots/拉钩App首页.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wangrui460/WRNavigationBar_swift/e9e9bd77d0dc856dd872937351e2024c5407d74f/screenshots/拉钩App首页.gif
--------------------------------------------------------------------------------
/screenshots/效果图.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wangrui460/WRNavigationBar_swift/e9e9bd77d0dc856dd872937351e2024c5407d74f/screenshots/效果图.png
--------------------------------------------------------------------------------
/screenshots/新浪微博个人中心.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wangrui460/WRNavigationBar_swift/e9e9bd77d0dc856dd872937351e2024c5407d74f/screenshots/新浪微博个人中心.gif
--------------------------------------------------------------------------------
/screenshots/未处理右滑中断.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wangrui460/WRNavigationBar_swift/e9e9bd77d0dc856dd872937351e2024c5407d74f/screenshots/未处理右滑中断.gif
--------------------------------------------------------------------------------
/screenshots/未处理右滑返回手势.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wangrui460/WRNavigationBar_swift/e9e9bd77d0dc856dd872937351e2024c5407d74f/screenshots/未处理右滑返回手势.gif
--------------------------------------------------------------------------------
/screenshots/知乎日报.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wangrui460/WRNavigationBar_swift/e9e9bd77d0dc856dd872937351e2024c5407d74f/screenshots/知乎日报.gif
--------------------------------------------------------------------------------
/screenshots/移动导航栏.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wangrui460/WRNavigationBar_swift/e9e9bd77d0dc856dd872937351e2024c5407d74f/screenshots/移动导航栏.gif
--------------------------------------------------------------------------------
/screenshots/自定义导航栏.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wangrui460/WRNavigationBar_swift/e9e9bd77d0dc856dd872937351e2024c5407d74f/screenshots/自定义导航栏.gif
--------------------------------------------------------------------------------
/screenshots/蚂蚁森林.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wangrui460/WRNavigationBar_swift/e9e9bd77d0dc856dd872937351e2024c5407d74f/screenshots/蚂蚁森林.gif
--------------------------------------------------------------------------------
/screenshots/连续多个界面导航栏透明.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wangrui460/WRNavigationBar_swift/e9e9bd77d0dc856dd872937351e2024c5407d74f/screenshots/连续多个界面导航栏透明.gif
--------------------------------------------------------------------------------