├── .gitignore ├── Example ├── AppDelegate.swift ├── Assets.xcassets │ └── AppIcon.appiconset │ │ └── Contents.json ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard ├── Info.plist ├── MainViewController.swift ├── NavigationBarData.swift ├── NavigationController.swift ├── SettingsViewController.swift └── UIImage+Color.swift ├── KMNavigationBarTransition.podspec ├── KMNavigationBarTransition.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ └── contents.xcworkspacedata └── xcshareddata │ └── xcschemes │ ├── KMNavigationBarTransition-Example.xcscheme │ └── KMNavigationBarTransition.xcscheme ├── KMNavigationBarTransition ├── Info.plist ├── KMNavigationBarTransition.h ├── KMSwizzle.h ├── KMSwizzle.m ├── KMWeakObjectContainer.h ├── KMWeakObjectContainer.m ├── NSObject+KMNavigationBarTransition.h ├── NSObject+KMNavigationBarTransition.m ├── UINavigationBar+KMNavigationBarTransition.h ├── UINavigationBar+KMNavigationBarTransition.m ├── UINavigationBar+KMNavigationBarTransition_internal.h ├── UINavigationController+KMNavigationBarTransition.h ├── UINavigationController+KMNavigationBarTransition.m ├── UINavigationController+KMNavigationBarTransition_internal.h ├── UIScrollView+KMNavigationBarTransition.h ├── UIScrollView+KMNavigationBarTransition.m ├── UIScrollView+KMNavigationBarTransition_internal.h ├── UIViewController+KMNavigationBarTransition.h ├── UIViewController+KMNavigationBarTransition.m └── UIViewController+KMNavigationBarTransition_internal.h ├── LICENSE ├── README.md ├── README_CN.md └── Screenshots ├── Before1.gif ├── Before2.gif ├── Now1.gif └── Now2.gif /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | build/ 4 | *.pbxuser 5 | !default.pbxuser 6 | *.mode1v3 7 | !default.mode1v3 8 | *.mode2v3 9 | !default.mode2v3 10 | *.perspectivev3 11 | !default.perspectivev3 12 | xcuserdata 13 | *.xccheckout 14 | *.moved-aside 15 | DerivedData 16 | *.hmap 17 | *.ipa 18 | *.xcuserstate -------------------------------------------------------------------------------- /Example/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // KMNavigationBarTransition 4 | // 5 | // Created by Zhouqi Mo on 1/1/16. 6 | // Copyright © 2017 Zhouqi Mo. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @UIApplicationMain 12 | class AppDelegate: UIResponder, UIApplicationDelegate { 13 | 14 | var window: UIWindow? 15 | 16 | 17 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { 18 | // Override point for customization after application launch. 19 | return true 20 | } 21 | 22 | func applicationWillResignActive(_ application: UIApplication) { 23 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 24 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. 25 | } 26 | 27 | func applicationDidEnterBackground(_ application: UIApplication) { 28 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 29 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 30 | } 31 | 32 | func applicationWillEnterForeground(_ application: UIApplication) { 33 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. 34 | } 35 | 36 | func applicationDidBecomeActive(_ application: UIApplication) { 37 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 38 | } 39 | 40 | func applicationWillTerminate(_ application: UIApplication) { 41 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 42 | } 43 | 44 | 45 | } 46 | 47 | -------------------------------------------------------------------------------- /Example/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "ipad", 35 | "size" : "29x29", 36 | "scale" : "1x" 37 | }, 38 | { 39 | "idiom" : "ipad", 40 | "size" : "29x29", 41 | "scale" : "2x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "40x40", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "40x40", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "76x76", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "76x76", 61 | "scale" : "2x" 62 | }, 63 | { 64 | "idiom" : "ipad", 65 | "size" : "83.5x83.5", 66 | "scale" : "2x" 67 | } 68 | ], 69 | "info" : { 70 | "version" : 1, 71 | "author" : "xcode" 72 | } 73 | } -------------------------------------------------------------------------------- /Example/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 | -------------------------------------------------------------------------------- /Example/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 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 84 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 108 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | -------------------------------------------------------------------------------- /Example/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 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | UIInterfaceOrientationLandscapeLeft 37 | UIInterfaceOrientationLandscapeRight 38 | UIInterfaceOrientationPortraitUpsideDown 39 | 40 | UISupportedInterfaceOrientations~ipad 41 | 42 | UIInterfaceOrientationPortrait 43 | UIInterfaceOrientationPortraitUpsideDown 44 | UIInterfaceOrientationLandscapeLeft 45 | UIInterfaceOrientationLandscapeRight 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /Example/MainViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MainViewController.swift 3 | // KMNavigationBarTransition 4 | // 5 | // Created by Zhouqi Mo on 1/1/16. 6 | // Copyright © 2017 Zhouqi Mo. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class MainViewController: UITableViewController { 12 | 13 | // MARK: Constants 14 | 15 | struct Constants { 16 | struct Segue { 17 | static let ShowNextIdentifier = "Show Next" 18 | static let SetStyleIdentifier = "Set Style" 19 | } 20 | } 21 | 22 | // MARK: Properties 23 | 24 | var currentNavigationBarData: NavigationBarData! 25 | var nextNavigationBarData: NavigationBarData! 26 | 27 | @IBOutlet weak var nextNavigationBarTintColorText: UILabel! 28 | @IBOutlet weak var nextNavigatioBarBackgroundImageColorText: UILabel! 29 | @IBOutlet weak var nextNavigationBarPrefersHiddenSwitch: UISwitch! 30 | @IBOutlet weak var nextNavigationBarPrefersShadowImageHiddenSwitch: UISwitch! 31 | 32 | // MARK: View Life Cycle 33 | 34 | override func viewDidLoad() { 35 | super.viewDidLoad() 36 | if currentNavigationBarData == nil { 37 | currentNavigationBarData = NavigationBarData() 38 | } 39 | nextNavigationBarData = currentNavigationBarData 40 | 41 | nextNavigationBarTintColorText.text = nextNavigationBarData.barTintColor.rawValue 42 | nextNavigatioBarBackgroundImageColorText.text = nextNavigationBarData.backgroundImageColor.rawValue 43 | nextNavigationBarPrefersHiddenSwitch.isOn = nextNavigationBarData.prefersHidden 44 | nextNavigationBarPrefersShadowImageHiddenSwitch.isOn = nextNavigationBarData.prefersShadowImageHidden 45 | 46 | if #available(iOS 15.0, *) { 47 | let navigationBarAppearance = UINavigationBarAppearance() 48 | if navigationController?.navigationBar.isTranslucent ?? false { 49 | navigationBarAppearance.configureWithTransparentBackground() 50 | } else { 51 | navigationBarAppearance.configureWithOpaqueBackground() 52 | } 53 | navigationBarAppearance.backgroundColor = currentNavigationBarData.barTintColor.toUIColor 54 | navigationBarAppearance.backgroundImage = currentNavigationBarData.backgroundImageColor.toUIImage 55 | navigationBarAppearance.shadowImage = (currentNavigationBarData.prefersShadowImageHidden) ? UIImage() : nil 56 | navigationController?.navigationBar.standardAppearance = navigationBarAppearance 57 | navigationController?.navigationBar.scrollEdgeAppearance = navigationBarAppearance 58 | } else { 59 | navigationController?.navigationBar.barTintColor = currentNavigationBarData.barTintColor.toUIColor 60 | navigationController?.navigationBar.setBackgroundImage(currentNavigationBarData.backgroundImageColor.toUIImage, for: .default) 61 | navigationController?.navigationBar.shadowImage = (currentNavigationBarData.prefersShadowImageHidden) ? UIImage() : nil 62 | } 63 | 64 | 65 | title = "Title " + "\(navigationController!.viewControllers.count)" 66 | } 67 | 68 | override func viewWillAppear(_ animated: Bool) { 69 | super.viewWillAppear(animated) 70 | navigationController?.setNavigationBarHidden(currentNavigationBarData.prefersHidden, animated: animated) 71 | } 72 | 73 | } 74 | 75 | // MARK: - Target Action 76 | 77 | extension MainViewController { 78 | 79 | @IBAction func nextNavigationBarPrefersShadowImageHidden(_ sender: UISwitch) { 80 | nextNavigationBarData.prefersShadowImageHidden = sender.isOn 81 | } 82 | 83 | @IBAction func nextNavigationBarPrefersHidden(_ sender: UISwitch) { 84 | nextNavigationBarData.prefersHidden = sender.isOn 85 | } 86 | 87 | @IBAction func navigationBarTranslucent(_ sender: UISwitch) { 88 | navigationController?.navigationBar.isTranslucent = sender.isOn 89 | } 90 | 91 | } 92 | 93 | // MARK: - Table view data source 94 | 95 | extension MainViewController { 96 | 97 | override func numberOfSections(in tableView: UITableView) -> Int { 98 | return navigationController?.viewControllers.first == self ? 2 : 1 99 | } 100 | 101 | } 102 | 103 | // MARK: - Table view delegate 104 | 105 | extension MainViewController { 106 | 107 | override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { 108 | switch (indexPath.section, indexPath.row) { 109 | case (0, 0), (0, 1): 110 | performSegue(withIdentifier: Constants.Segue.SetStyleIdentifier, sender: self) 111 | default: 112 | break 113 | } 114 | } 115 | 116 | } 117 | 118 | // MARK: - Navigation 119 | 120 | extension MainViewController { 121 | 122 | override func prepare(for segue: UIStoryboardSegue, sender: Any?) { 123 | if let identifier = segue.identifier { 124 | switch identifier { 125 | case Constants.Segue.SetStyleIdentifier: 126 | guard let settingsViewController = segue.destination as? SettingsViewController else { 127 | return 128 | } 129 | guard let selectedIndexPath = tableView.indexPathForSelectedRow else { 130 | return 131 | } 132 | 133 | var colorsArray = [NavigationBarBackgroundViewColor]() 134 | var selectedIndex: Int? 135 | var block: ((_ color: NavigationBarBackgroundViewColor) -> Void)? 136 | 137 | switch (selectedIndexPath.section, selectedIndexPath.row) { 138 | case (0, 0): 139 | colorsArray = NavigationBarData.BarTintColorArray 140 | selectedIndex = colorsArray.index(of: NavigationBarBackgroundViewColor(rawValue: nextNavigationBarTintColorText.text!)!) 141 | block = { 142 | self.nextNavigationBarData.barTintColor = $0 143 | self.nextNavigationBarTintColorText.text = $0.rawValue 144 | } 145 | case (0, 1): 146 | colorsArray = NavigationBarData.BackgroundImageColorArray 147 | selectedIndex = colorsArray.index(of: NavigationBarBackgroundViewColor(rawValue: nextNavigatioBarBackgroundImageColorText.text!)!) 148 | block = { 149 | self.nextNavigationBarData.backgroundImageColor = $0 150 | self.nextNavigatioBarBackgroundImageColorText.text = $0.rawValue 151 | } 152 | default: 153 | break 154 | } 155 | settingsViewController.colorsData = (colorsArray, selectedIndex) 156 | settingsViewController.configurationBlock = block 157 | settingsViewController.titleText = tableView.cellForRow(at: selectedIndexPath)?.textLabel?.text ?? "" 158 | 159 | case Constants.Segue.ShowNextIdentifier: 160 | guard let viewController = segue.destination as? MainViewController else { 161 | return 162 | } 163 | viewController.currentNavigationBarData = nextNavigationBarData 164 | break 165 | default: 166 | break 167 | } 168 | } 169 | } 170 | 171 | } 172 | -------------------------------------------------------------------------------- /Example/NavigationBarData.swift: -------------------------------------------------------------------------------- 1 | // 2 | // NavigationBarData.swift 3 | // KMNavigationBarTransition 4 | // 5 | // Created by Zhouqi Mo on 1/1/16. 6 | // Copyright © 2017 Zhouqi Mo. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | struct NavigationBarData { 12 | 13 | static let BarTintColorArray: [NavigationBarBackgroundViewColor] = [.Cyan, .Yellow, .Green, .Orange, .lightGray, .NoValue] 14 | static let BackgroundImageColorArray: [NavigationBarBackgroundViewColor] = [.NoValue, .Transparent, .Cyan, .Yellow, .Green, .Orange, .lightGray] 15 | 16 | var barTintColor = NavigationBarData.BarTintColorArray.first! 17 | var backgroundImageColor = NavigationBarData.BackgroundImageColorArray.first! 18 | var prefersHidden = false 19 | var prefersShadowImageHidden = false 20 | 21 | } 22 | 23 | enum NavigationBarBackgroundViewColor: String { 24 | case Cyan 25 | case Yellow 26 | case Green 27 | case Orange 28 | case lightGray 29 | case Transparent 30 | case NoValue = "No Value" 31 | 32 | var toUIColor: UIColor? { 33 | switch self { 34 | case .Cyan: 35 | return UIColor.cyan 36 | case .Yellow: 37 | return UIColor.yellow 38 | case .Green: 39 | return UIColor.green 40 | case .Orange: 41 | return UIColor.orange 42 | case .lightGray: 43 | return UIColor.lightGray 44 | default: 45 | return nil 46 | } 47 | } 48 | 49 | var toUIImage: UIImage? { 50 | switch self { 51 | case .Transparent: 52 | return UIImage() 53 | default: 54 | if let color = toUIColor { 55 | return UIImage(color: color) 56 | } else { 57 | return nil 58 | } 59 | } 60 | } 61 | } 62 | 63 | -------------------------------------------------------------------------------- /Example/NavigationController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // NavigationController.swift 3 | // KMNavigationBarTransition 4 | // 5 | // Created by Zhouqi Mo on 1/1/16. 6 | // Copyright © 2017 Zhouqi Mo. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class NavigationController: UINavigationController { 12 | 13 | // MARK: View Life Cycle 14 | 15 | override func viewDidLoad() { 16 | super.viewDidLoad() 17 | self.interactivePopGestureRecognizer?.delegate = self 18 | } 19 | 20 | } 21 | 22 | // MARK: Gesture Recognizer Delegate 23 | 24 | extension NavigationController: UIGestureRecognizerDelegate { 25 | 26 | func gestureRecognizerShouldBegin(_ gestureRecognizer: UIGestureRecognizer) -> Bool { 27 | 28 | // Ignore interactive pop gesture when there is only one view controller on the navigation stack 29 | if viewControllers.count <= 1 { 30 | return false 31 | } 32 | return true 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /Example/SettingsViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SettingsViewController.swift 3 | // KMNavigationBarTransition 4 | // 5 | // Created by Zhouqi Mo on 1/1/16. 6 | // Copyright © 2017 Zhouqi Mo. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class SettingsViewController: UITableViewController { 12 | 13 | // MARK: Constants 14 | 15 | struct Constants { 16 | struct TableViewCell { 17 | static let Identifier = "Cell" 18 | } 19 | } 20 | 21 | // MARK: Properties 22 | 23 | var colorsData: (colorsArray: [NavigationBarBackgroundViewColor], selectedIndex: Int?)! 24 | var configurationBlock: ((_ color: NavigationBarBackgroundViewColor) -> Void)! 25 | var titleText = "" 26 | 27 | // MARK: View Life Cycle 28 | 29 | override func viewDidLoad() { 30 | title = titleText 31 | } 32 | 33 | } 34 | 35 | // MARK: - Table view data source 36 | 37 | extension SettingsViewController { 38 | 39 | override func numberOfSections(in tableView: UITableView) -> Int { 40 | return 1 41 | } 42 | 43 | override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { 44 | return colorsData.colorsArray.count 45 | } 46 | 47 | override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { 48 | let cell = tableView.dequeueReusableCell(withIdentifier: Constants.TableViewCell.Identifier, for: indexPath) 49 | cell.textLabel?.text = colorsData.colorsArray[indexPath.row].rawValue 50 | cell.accessoryType = (indexPath.row == colorsData.selectedIndex) ? .checkmark : .none 51 | 52 | return cell 53 | } 54 | 55 | } 56 | 57 | // MARK: - Table view delegate 58 | 59 | extension SettingsViewController { 60 | 61 | override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { 62 | if let selectedIndex = colorsData.selectedIndex { 63 | tableView.cellForRow(at: IndexPath(row: selectedIndex, section: 0))?.accessoryType = .none 64 | } 65 | colorsData.selectedIndex = indexPath.row 66 | tableView.cellForRow(at: indexPath)?.accessoryType = .checkmark 67 | tableView.deselectRow(at: indexPath, animated: true) 68 | configurationBlock?(colorsData.colorsArray[indexPath.row]) 69 | } 70 | 71 | } 72 | -------------------------------------------------------------------------------- /Example/UIImage+Color.swift: -------------------------------------------------------------------------------- 1 | // 2 | // UIImage+Color.swift 3 | // KMNavigationBarTransition 4 | // 5 | // Created by Zhouqi Mo on 1/1/16. 6 | // Copyright © 2017 Zhouqi Mo. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | public extension UIImage { 12 | 13 | convenience init(color: UIColor, size: CGSize = CGSize(width: 1, height: 1)) { 14 | let rect = CGRect(x: 0, y: 0, width: size.width, height: size.height) 15 | UIGraphicsBeginImageContextWithOptions(rect.size, false, 0) 16 | color.setFill() 17 | UIRectFill(rect) 18 | let image = UIGraphicsGetImageFromCurrentImageContext() 19 | UIGraphicsEndImageContext() 20 | self.init(cgImage: (image?.cgImage!)!) 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /KMNavigationBarTransition.podspec: -------------------------------------------------------------------------------- 1 | Pod::Spec.new do |s| 2 | 3 | s.name = "KMNavigationBarTransition" 4 | s.version = "1.1.11" 5 | s.summary = "A drop-in universal library makes transition animations smooth between different navigation bar styles while pushing or popping." 6 | 7 | s.description = <<-DESC 8 | A drop-in universal library helps you to manage the navigation bar styles and makes transition animations smooth between different navigation bar styles while pushing or popping a view controller for all orientations. And you don't need to write any line of code for it, it all happens automatically. 9 | 10 | The design concept of the library is that what you only need to care about is the background style of the navigation bar in the *current* view controller, without handling the various background styles while pushing or popping. 11 | 12 | The library can capture the background style of the navigation bar in the disappearing view controller when pushing, and when you pop back to the view controller, the navigation bar will restore the previous style, so you don't need to consider the background style after popping. And you also don't need to consider it after pushing, because it is the view controller to be pushed that needs to be considered. 13 | DESC 14 | 15 | s.homepage = "https://github.com/MoZhouqi/KMNavigationBarTransition" 16 | s.screenshots = "https://raw.githubusercontent.com/MoZhouqi/KMNavigationBarTransition/master/Screenshots/Now2.gif" 17 | 18 | s.license = "MIT" 19 | 20 | s.author = { "Zhouqi Mo" => "mozhouqi@gmail.com" } 21 | s.social_media_url = "https://twitter.com/MoZhouqi" 22 | 23 | s.platform = :ios, "9.0" 24 | 25 | s.source = { :git => "https://github.com/MoZhouqi/KMNavigationBarTransition.git", :tag => s.version } 26 | 27 | s.source_files = "KMNavigationBarTransition/*.{h,m}" 28 | 29 | s.frameworks = "UIKit" 30 | 31 | s.requires_arc = true 32 | 33 | end 34 | -------------------------------------------------------------------------------- /KMNavigationBarTransition.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | CD4209391F7A47CF00A1EAF5 /* UIScrollView+KMNavigationBarTransition.h in Headers */ = {isa = PBXBuildFile; fileRef = CDE74D801F7A457C003052BE /* UIScrollView+KMNavigationBarTransition.h */; }; 11 | CDA372851C39087D00E39A6D /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = CDA372841C39087D00E39A6D /* AppDelegate.swift */; }; 12 | CDA372881C39089200E39A6D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = CDA372861C39089200E39A6D /* Main.storyboard */; }; 13 | CDA3728A1C39089900E39A6D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = CDA372891C39089900E39A6D /* Assets.xcassets */; }; 14 | CDA3728D1C3908A000E39A6D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = CDA3728B1C3908A000E39A6D /* LaunchScreen.storyboard */; }; 15 | CDA372951C39093E00E39A6D /* MainViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = CDA372901C39093E00E39A6D /* MainViewController.swift */; }; 16 | CDA372961C39093E00E39A6D /* NavigationBarData.swift in Sources */ = {isa = PBXBuildFile; fileRef = CDA372911C39093E00E39A6D /* NavigationBarData.swift */; }; 17 | CDA372971C39093E00E39A6D /* NavigationController.swift in Sources */ = {isa = PBXBuildFile; fileRef = CDA372921C39093E00E39A6D /* NavigationController.swift */; }; 18 | CDA372981C39093E00E39A6D /* SettingsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = CDA372931C39093E00E39A6D /* SettingsViewController.swift */; }; 19 | CDA372991C39093E00E39A6D /* UIImage+Color.swift in Sources */ = {isa = PBXBuildFile; fileRef = CDA372941C39093E00E39A6D /* UIImage+Color.swift */; }; 20 | CDAA3BB31E5CB40E00666BB0 /* UIViewController+KMNavigationBarTransition_internal.h in Headers */ = {isa = PBXBuildFile; fileRef = CDAA3BB21E5CB40E00666BB0 /* UIViewController+KMNavigationBarTransition_internal.h */; }; 21 | CDC01B971E5CA42000F6F3E2 /* KMNavigationBarTransition.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CDC01B901E5CA42000F6F3E2 /* KMNavigationBarTransition.framework */; }; 22 | CDC01B981E5CA42000F6F3E2 /* KMNavigationBarTransition.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = CDC01B901E5CA42000F6F3E2 /* KMNavigationBarTransition.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 23 | CDC01B9D1E5CA46400F6F3E2 /* KMNavigationBarTransition.h in Headers */ = {isa = PBXBuildFile; fileRef = CDC01B9C1E5CA46400F6F3E2 /* KMNavigationBarTransition.h */; settings = {ATTRIBUTES = (Public, ); }; }; 24 | CDC01B9F1E5CA48400F6F3E2 /* UINavigationController+KMNavigationBarTransition.h in Headers */ = {isa = PBXBuildFile; fileRef = CDDFA1F31C3921BD00BFBA1B /* UINavigationController+KMNavigationBarTransition.h */; settings = {ATTRIBUTES = (Public, ); }; }; 25 | CDC01BA11E5CA48900F6F3E2 /* UIViewController+KMNavigationBarTransition.h in Headers */ = {isa = PBXBuildFile; fileRef = CDDFA1F51C3921BD00BFBA1B /* UIViewController+KMNavigationBarTransition.h */; }; 26 | CDC01BA21E5CA48B00F6F3E2 /* UIViewController+KMNavigationBarTransition.m in Sources */ = {isa = PBXBuildFile; fileRef = CDDFA1F61C3921BD00BFBA1B /* UIViewController+KMNavigationBarTransition.m */; }; 27 | CDC01BA31E5CA48D00F6F3E2 /* KMWeakObjectContainer.h in Headers */ = {isa = PBXBuildFile; fileRef = CDC1BA0C1CE1DFE8006BE1B6 /* KMWeakObjectContainer.h */; }; 28 | CDC01BA41E5CA48F00F6F3E2 /* KMWeakObjectContainer.m in Sources */ = {isa = PBXBuildFile; fileRef = CDC1BA0D1CE1DFE8006BE1B6 /* KMWeakObjectContainer.m */; }; 29 | CDC01BA51E5CA49100F6F3E2 /* KMSwizzle.h in Headers */ = {isa = PBXBuildFile; fileRef = CDDFA1F11C3921BD00BFBA1B /* KMSwizzle.h */; }; 30 | CDC01BA61E5CA49300F6F3E2 /* KMSwizzle.m in Sources */ = {isa = PBXBuildFile; fileRef = CDDFA1F21C3921BD00BFBA1B /* KMSwizzle.m */; }; 31 | CDC01BA71E5CA67A00F6F3E2 /* UINavigationController+KMNavigationBarTransition.m in Sources */ = {isa = PBXBuildFile; fileRef = CDDFA1F41C3921BD00BFBA1B /* UINavigationController+KMNavigationBarTransition.m */; }; 32 | CDC01BAA1E5CA82800F6F3E2 /* UINavigationController+KMNavigationBarTransition_internal.h in Headers */ = {isa = PBXBuildFile; fileRef = CDC01BA81E5CA82800F6F3E2 /* UINavigationController+KMNavigationBarTransition_internal.h */; }; 33 | CDC722AD1F7257EE0077084B /* UINavigationBar+KMNavigationBarTransition.h in Headers */ = {isa = PBXBuildFile; fileRef = CDC722AB1F7257EE0077084B /* UINavigationBar+KMNavigationBarTransition.h */; }; 34 | CDC722AE1F7257EE0077084B /* UINavigationBar+KMNavigationBarTransition.m in Sources */ = {isa = PBXBuildFile; fileRef = CDC722AC1F7257EE0077084B /* UINavigationBar+KMNavigationBarTransition.m */; }; 35 | CDC722B01F72590C0077084B /* UINavigationBar+KMNavigationBarTransition_internal.h in Headers */ = {isa = PBXBuildFile; fileRef = CDC722AF1F72590C0077084B /* UINavigationBar+KMNavigationBarTransition_internal.h */; }; 36 | CDC722B31F72599F0077084B /* NSObject+KMNavigationBarTransition.h in Headers */ = {isa = PBXBuildFile; fileRef = CDC722B11F72599F0077084B /* NSObject+KMNavigationBarTransition.h */; }; 37 | CDC722B41F72599F0077084B /* NSObject+KMNavigationBarTransition.m in Sources */ = {isa = PBXBuildFile; fileRef = CDC722B21F72599F0077084B /* NSObject+KMNavigationBarTransition.m */; }; 38 | CDD35A4C1F94CABE00EFDBD8 /* UIScrollView+KMNavigationBarTransition_internal.h in Headers */ = {isa = PBXBuildFile; fileRef = CDD35A4B1F94CABE00EFDBD8 /* UIScrollView+KMNavigationBarTransition_internal.h */; }; 39 | CDE74D821F7A457C003052BE /* UIScrollView+KMNavigationBarTransition.m in Sources */ = {isa = PBXBuildFile; fileRef = CDE74D811F7A457C003052BE /* UIScrollView+KMNavigationBarTransition.m */; }; 40 | /* End PBXBuildFile section */ 41 | 42 | /* Begin PBXContainerItemProxy section */ 43 | CDC01B951E5CA42000F6F3E2 /* PBXContainerItemProxy */ = { 44 | isa = PBXContainerItemProxy; 45 | containerPortal = CDA372671C3907CE00E39A6D /* Project object */; 46 | proxyType = 1; 47 | remoteGlobalIDString = CDC01B8F1E5CA42000F6F3E2; 48 | remoteInfo = KMNavigationBarTransition; 49 | }; 50 | /* End PBXContainerItemProxy section */ 51 | 52 | /* Begin PBXCopyFilesBuildPhase section */ 53 | CDC01B791E5CA40A00F6F3E2 /* Embed Frameworks */ = { 54 | isa = PBXCopyFilesBuildPhase; 55 | buildActionMask = 2147483647; 56 | dstPath = ""; 57 | dstSubfolderSpec = 10; 58 | files = ( 59 | CDC01B981E5CA42000F6F3E2 /* KMNavigationBarTransition.framework in Embed Frameworks */, 60 | ); 61 | name = "Embed Frameworks"; 62 | runOnlyForDeploymentPostprocessing = 0; 63 | }; 64 | /* End PBXCopyFilesBuildPhase section */ 65 | 66 | /* Begin PBXFileReference section */ 67 | CDA3726F1C3907CE00E39A6D /* KMNavigationBarTransition-Example.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "KMNavigationBarTransition-Example.app"; sourceTree = BUILT_PRODUCTS_DIR; }; 68 | CDA372841C39087D00E39A6D /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = AppDelegate.swift; path = Example/AppDelegate.swift; sourceTree = SOURCE_ROOT; }; 69 | CDA372871C39089200E39A6D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Example/Base.lproj/Main.storyboard; sourceTree = SOURCE_ROOT; }; 70 | CDA372891C39089900E39A6D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = Assets.xcassets; path = Example/Assets.xcassets; sourceTree = SOURCE_ROOT; }; 71 | CDA3728C1C3908A000E39A6D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Example/Base.lproj/LaunchScreen.storyboard; sourceTree = SOURCE_ROOT; }; 72 | CDA3728E1C3908A500E39A6D /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = Example/Info.plist; sourceTree = SOURCE_ROOT; }; 73 | CDA372901C39093E00E39A6D /* MainViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = MainViewController.swift; path = Example/MainViewController.swift; sourceTree = SOURCE_ROOT; }; 74 | CDA372911C39093E00E39A6D /* NavigationBarData.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = NavigationBarData.swift; path = Example/NavigationBarData.swift; sourceTree = SOURCE_ROOT; }; 75 | CDA372921C39093E00E39A6D /* NavigationController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = NavigationController.swift; path = Example/NavigationController.swift; sourceTree = SOURCE_ROOT; }; 76 | CDA372931C39093E00E39A6D /* SettingsViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SettingsViewController.swift; path = Example/SettingsViewController.swift; sourceTree = SOURCE_ROOT; }; 77 | CDA372941C39093E00E39A6D /* UIImage+Color.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = "UIImage+Color.swift"; path = "Example/UIImage+Color.swift"; sourceTree = SOURCE_ROOT; }; 78 | CDAA3BB21E5CB40E00666BB0 /* UIViewController+KMNavigationBarTransition_internal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIViewController+KMNavigationBarTransition_internal.h"; sourceTree = ""; }; 79 | CDC01B901E5CA42000F6F3E2 /* KMNavigationBarTransition.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = KMNavigationBarTransition.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 80 | CDC01B9C1E5CA46400F6F3E2 /* KMNavigationBarTransition.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KMNavigationBarTransition.h; sourceTree = ""; }; 81 | CDC01B9E1E5CA46900F6F3E2 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 82 | CDC01BA81E5CA82800F6F3E2 /* UINavigationController+KMNavigationBarTransition_internal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UINavigationController+KMNavigationBarTransition_internal.h"; sourceTree = ""; }; 83 | CDC1BA0C1CE1DFE8006BE1B6 /* KMWeakObjectContainer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KMWeakObjectContainer.h; sourceTree = ""; }; 84 | CDC1BA0D1CE1DFE8006BE1B6 /* KMWeakObjectContainer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KMWeakObjectContainer.m; sourceTree = ""; }; 85 | CDC722AB1F7257EE0077084B /* UINavigationBar+KMNavigationBarTransition.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UINavigationBar+KMNavigationBarTransition.h"; sourceTree = ""; }; 86 | CDC722AC1F7257EE0077084B /* UINavigationBar+KMNavigationBarTransition.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UINavigationBar+KMNavigationBarTransition.m"; sourceTree = ""; }; 87 | CDC722AF1F72590C0077084B /* UINavigationBar+KMNavigationBarTransition_internal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UINavigationBar+KMNavigationBarTransition_internal.h"; sourceTree = ""; }; 88 | CDC722B11F72599F0077084B /* NSObject+KMNavigationBarTransition.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSObject+KMNavigationBarTransition.h"; sourceTree = ""; }; 89 | CDC722B21F72599F0077084B /* NSObject+KMNavigationBarTransition.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSObject+KMNavigationBarTransition.m"; sourceTree = ""; }; 90 | CDD35A4B1F94CABE00EFDBD8 /* UIScrollView+KMNavigationBarTransition_internal.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "UIScrollView+KMNavigationBarTransition_internal.h"; sourceTree = ""; }; 91 | CDDFA1F11C3921BD00BFBA1B /* KMSwizzle.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KMSwizzle.h; sourceTree = ""; }; 92 | CDDFA1F21C3921BD00BFBA1B /* KMSwizzle.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KMSwizzle.m; sourceTree = ""; }; 93 | CDDFA1F31C3921BD00BFBA1B /* UINavigationController+KMNavigationBarTransition.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UINavigationController+KMNavigationBarTransition.h"; sourceTree = ""; }; 94 | CDDFA1F41C3921BD00BFBA1B /* UINavigationController+KMNavigationBarTransition.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UINavigationController+KMNavigationBarTransition.m"; sourceTree = ""; }; 95 | CDDFA1F51C3921BD00BFBA1B /* UIViewController+KMNavigationBarTransition.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIViewController+KMNavigationBarTransition.h"; sourceTree = ""; }; 96 | CDDFA1F61C3921BD00BFBA1B /* UIViewController+KMNavigationBarTransition.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIViewController+KMNavigationBarTransition.m"; sourceTree = ""; }; 97 | CDE74D801F7A457C003052BE /* UIScrollView+KMNavigationBarTransition.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIScrollView+KMNavigationBarTransition.h"; sourceTree = ""; }; 98 | CDE74D811F7A457C003052BE /* UIScrollView+KMNavigationBarTransition.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIScrollView+KMNavigationBarTransition.m"; sourceTree = ""; }; 99 | /* End PBXFileReference section */ 100 | 101 | /* Begin PBXFrameworksBuildPhase section */ 102 | CDA3726C1C3907CE00E39A6D /* Frameworks */ = { 103 | isa = PBXFrameworksBuildPhase; 104 | buildActionMask = 2147483647; 105 | files = ( 106 | CDC01B971E5CA42000F6F3E2 /* KMNavigationBarTransition.framework in Frameworks */, 107 | ); 108 | runOnlyForDeploymentPostprocessing = 0; 109 | }; 110 | CDC01B8C1E5CA42000F6F3E2 /* Frameworks */ = { 111 | isa = PBXFrameworksBuildPhase; 112 | buildActionMask = 2147483647; 113 | files = ( 114 | ); 115 | runOnlyForDeploymentPostprocessing = 0; 116 | }; 117 | /* End PBXFrameworksBuildPhase section */ 118 | 119 | /* Begin PBXGroup section */ 120 | CDA372661C3907CE00E39A6D = { 121 | isa = PBXGroup; 122 | children = ( 123 | CDDFA1F01C3921BD00BFBA1B /* KMNavigationBarTransition */, 124 | CDA372711C3907CE00E39A6D /* Example */, 125 | CDA372701C3907CE00E39A6D /* Products */, 126 | ); 127 | sourceTree = ""; 128 | }; 129 | CDA372701C3907CE00E39A6D /* Products */ = { 130 | isa = PBXGroup; 131 | children = ( 132 | CDA3726F1C3907CE00E39A6D /* KMNavigationBarTransition-Example.app */, 133 | CDC01B901E5CA42000F6F3E2 /* KMNavigationBarTransition.framework */, 134 | ); 135 | name = Products; 136 | sourceTree = ""; 137 | }; 138 | CDA372711C3907CE00E39A6D /* Example */ = { 139 | isa = PBXGroup; 140 | children = ( 141 | CDA372861C39089200E39A6D /* Main.storyboard */, 142 | CDA372901C39093E00E39A6D /* MainViewController.swift */, 143 | CDA372931C39093E00E39A6D /* SettingsViewController.swift */, 144 | CDA372921C39093E00E39A6D /* NavigationController.swift */, 145 | CDA3729A1C39094600E39A6D /* Model */, 146 | CDA3729B1C39094B00E39A6D /* Extension */, 147 | CDA372841C39087D00E39A6D /* AppDelegate.swift */, 148 | CDA372891C39089900E39A6D /* Assets.xcassets */, 149 | CDA3728B1C3908A000E39A6D /* LaunchScreen.storyboard */, 150 | CDA3728E1C3908A500E39A6D /* Info.plist */, 151 | ); 152 | name = Example; 153 | path = KMNavigationBarTransition; 154 | sourceTree = ""; 155 | }; 156 | CDA3729A1C39094600E39A6D /* Model */ = { 157 | isa = PBXGroup; 158 | children = ( 159 | CDA372911C39093E00E39A6D /* NavigationBarData.swift */, 160 | ); 161 | name = Model; 162 | sourceTree = ""; 163 | }; 164 | CDA3729B1C39094B00E39A6D /* Extension */ = { 165 | isa = PBXGroup; 166 | children = ( 167 | CDA372941C39093E00E39A6D /* UIImage+Color.swift */, 168 | ); 169 | name = Extension; 170 | sourceTree = ""; 171 | }; 172 | CDDFA1F01C3921BD00BFBA1B /* KMNavigationBarTransition */ = { 173 | isa = PBXGroup; 174 | children = ( 175 | CDC01BA81E5CA82800F6F3E2 /* UINavigationController+KMNavigationBarTransition_internal.h */, 176 | CDDFA1F31C3921BD00BFBA1B /* UINavigationController+KMNavigationBarTransition.h */, 177 | CDDFA1F41C3921BD00BFBA1B /* UINavigationController+KMNavigationBarTransition.m */, 178 | CDAA3BB21E5CB40E00666BB0 /* UIViewController+KMNavigationBarTransition_internal.h */, 179 | CDDFA1F51C3921BD00BFBA1B /* UIViewController+KMNavigationBarTransition.h */, 180 | CDDFA1F61C3921BD00BFBA1B /* UIViewController+KMNavigationBarTransition.m */, 181 | CDC722AF1F72590C0077084B /* UINavigationBar+KMNavigationBarTransition_internal.h */, 182 | CDC722AB1F7257EE0077084B /* UINavigationBar+KMNavigationBarTransition.h */, 183 | CDC722AC1F7257EE0077084B /* UINavigationBar+KMNavigationBarTransition.m */, 184 | CDD35A4B1F94CABE00EFDBD8 /* UIScrollView+KMNavigationBarTransition_internal.h */, 185 | CDE74D801F7A457C003052BE /* UIScrollView+KMNavigationBarTransition.h */, 186 | CDE74D811F7A457C003052BE /* UIScrollView+KMNavigationBarTransition.m */, 187 | CDC722B11F72599F0077084B /* NSObject+KMNavigationBarTransition.h */, 188 | CDC722B21F72599F0077084B /* NSObject+KMNavigationBarTransition.m */, 189 | CDC1BA0C1CE1DFE8006BE1B6 /* KMWeakObjectContainer.h */, 190 | CDC1BA0D1CE1DFE8006BE1B6 /* KMWeakObjectContainer.m */, 191 | CDDFA1F11C3921BD00BFBA1B /* KMSwizzle.h */, 192 | CDDFA1F21C3921BD00BFBA1B /* KMSwizzle.m */, 193 | CDC01B9C1E5CA46400F6F3E2 /* KMNavigationBarTransition.h */, 194 | CDC01B9E1E5CA46900F6F3E2 /* Info.plist */, 195 | ); 196 | path = KMNavigationBarTransition; 197 | sourceTree = ""; 198 | }; 199 | /* End PBXGroup section */ 200 | 201 | /* Begin PBXHeadersBuildPhase section */ 202 | CDC01B8D1E5CA42000F6F3E2 /* Headers */ = { 203 | isa = PBXHeadersBuildPhase; 204 | buildActionMask = 2147483647; 205 | files = ( 206 | CDC01B9D1E5CA46400F6F3E2 /* KMNavigationBarTransition.h in Headers */, 207 | CDC722B31F72599F0077084B /* NSObject+KMNavigationBarTransition.h in Headers */, 208 | CDC01BAA1E5CA82800F6F3E2 /* UINavigationController+KMNavigationBarTransition_internal.h in Headers */, 209 | CDAA3BB31E5CB40E00666BB0 /* UIViewController+KMNavigationBarTransition_internal.h in Headers */, 210 | CDC01B9F1E5CA48400F6F3E2 /* UINavigationController+KMNavigationBarTransition.h in Headers */, 211 | CDC722B01F72590C0077084B /* UINavigationBar+KMNavigationBarTransition_internal.h in Headers */, 212 | CDD35A4C1F94CABE00EFDBD8 /* UIScrollView+KMNavigationBarTransition_internal.h in Headers */, 213 | CD4209391F7A47CF00A1EAF5 /* UIScrollView+KMNavigationBarTransition.h in Headers */, 214 | CDC01BA11E5CA48900F6F3E2 /* UIViewController+KMNavigationBarTransition.h in Headers */, 215 | CDC01BA31E5CA48D00F6F3E2 /* KMWeakObjectContainer.h in Headers */, 216 | CDC01BA51E5CA49100F6F3E2 /* KMSwizzle.h in Headers */, 217 | CDC722AD1F7257EE0077084B /* UINavigationBar+KMNavigationBarTransition.h in Headers */, 218 | ); 219 | runOnlyForDeploymentPostprocessing = 0; 220 | }; 221 | /* End PBXHeadersBuildPhase section */ 222 | 223 | /* Begin PBXNativeTarget section */ 224 | CDA3726E1C3907CE00E39A6D /* KMNavigationBarTransition-Example */ = { 225 | isa = PBXNativeTarget; 226 | buildConfigurationList = CDA372811C3907CE00E39A6D /* Build configuration list for PBXNativeTarget "KMNavigationBarTransition-Example" */; 227 | buildPhases = ( 228 | CDA3726B1C3907CE00E39A6D /* Sources */, 229 | CDA3726C1C3907CE00E39A6D /* Frameworks */, 230 | CDA3726D1C3907CE00E39A6D /* Resources */, 231 | CDC01B791E5CA40A00F6F3E2 /* Embed Frameworks */, 232 | ); 233 | buildRules = ( 234 | ); 235 | dependencies = ( 236 | CDC01B961E5CA42000F6F3E2 /* PBXTargetDependency */, 237 | ); 238 | name = "KMNavigationBarTransition-Example"; 239 | productName = KMNavigationBarTransition; 240 | productReference = CDA3726F1C3907CE00E39A6D /* KMNavigationBarTransition-Example.app */; 241 | productType = "com.apple.product-type.application"; 242 | }; 243 | CDC01B8F1E5CA42000F6F3E2 /* KMNavigationBarTransition */ = { 244 | isa = PBXNativeTarget; 245 | buildConfigurationList = CDC01B991E5CA42000F6F3E2 /* Build configuration list for PBXNativeTarget "KMNavigationBarTransition" */; 246 | buildPhases = ( 247 | CDC01B8B1E5CA42000F6F3E2 /* Sources */, 248 | CDC01B8C1E5CA42000F6F3E2 /* Frameworks */, 249 | CDC01B8D1E5CA42000F6F3E2 /* Headers */, 250 | CDC01B8E1E5CA42000F6F3E2 /* Resources */, 251 | ); 252 | buildRules = ( 253 | ); 254 | dependencies = ( 255 | ); 256 | name = KMNavigationBarTransition; 257 | productName = KMNavigationBarTransition; 258 | productReference = CDC01B901E5CA42000F6F3E2 /* KMNavigationBarTransition.framework */; 259 | productType = "com.apple.product-type.framework"; 260 | }; 261 | /* End PBXNativeTarget section */ 262 | 263 | /* Begin PBXProject section */ 264 | CDA372671C3907CE00E39A6D /* Project object */ = { 265 | isa = PBXProject; 266 | attributes = { 267 | LastSwiftUpdateCheck = 0720; 268 | LastUpgradeCheck = 0820; 269 | ORGANIZATIONNAME = "Zhouqi Mo"; 270 | TargetAttributes = { 271 | CDA3726E1C3907CE00E39A6D = { 272 | CreatedOnToolsVersion = 7.2; 273 | LastSwiftMigration = 0820; 274 | }; 275 | CDC01B8F1E5CA42000F6F3E2 = { 276 | CreatedOnToolsVersion = 8.2.1; 277 | ProvisioningStyle = Automatic; 278 | }; 279 | }; 280 | }; 281 | buildConfigurationList = CDA3726A1C3907CE00E39A6D /* Build configuration list for PBXProject "KMNavigationBarTransition" */; 282 | compatibilityVersion = "Xcode 3.2"; 283 | developmentRegion = English; 284 | hasScannedForEncodings = 0; 285 | knownRegions = ( 286 | English, 287 | en, 288 | Base, 289 | ); 290 | mainGroup = CDA372661C3907CE00E39A6D; 291 | productRefGroup = CDA372701C3907CE00E39A6D /* Products */; 292 | projectDirPath = ""; 293 | projectRoot = ""; 294 | targets = ( 295 | CDA3726E1C3907CE00E39A6D /* KMNavigationBarTransition-Example */, 296 | CDC01B8F1E5CA42000F6F3E2 /* KMNavigationBarTransition */, 297 | ); 298 | }; 299 | /* End PBXProject section */ 300 | 301 | /* Begin PBXResourcesBuildPhase section */ 302 | CDA3726D1C3907CE00E39A6D /* Resources */ = { 303 | isa = PBXResourcesBuildPhase; 304 | buildActionMask = 2147483647; 305 | files = ( 306 | CDA3728D1C3908A000E39A6D /* LaunchScreen.storyboard in Resources */, 307 | CDA3728A1C39089900E39A6D /* Assets.xcassets in Resources */, 308 | CDA372881C39089200E39A6D /* Main.storyboard in Resources */, 309 | ); 310 | runOnlyForDeploymentPostprocessing = 0; 311 | }; 312 | CDC01B8E1E5CA42000F6F3E2 /* Resources */ = { 313 | isa = PBXResourcesBuildPhase; 314 | buildActionMask = 2147483647; 315 | files = ( 316 | ); 317 | runOnlyForDeploymentPostprocessing = 0; 318 | }; 319 | /* End PBXResourcesBuildPhase section */ 320 | 321 | /* Begin PBXSourcesBuildPhase section */ 322 | CDA3726B1C3907CE00E39A6D /* Sources */ = { 323 | isa = PBXSourcesBuildPhase; 324 | buildActionMask = 2147483647; 325 | files = ( 326 | CDA372851C39087D00E39A6D /* AppDelegate.swift in Sources */, 327 | CDA372971C39093E00E39A6D /* NavigationController.swift in Sources */, 328 | CDA372951C39093E00E39A6D /* MainViewController.swift in Sources */, 329 | CDA372981C39093E00E39A6D /* SettingsViewController.swift in Sources */, 330 | CDA372961C39093E00E39A6D /* NavigationBarData.swift in Sources */, 331 | CDA372991C39093E00E39A6D /* UIImage+Color.swift in Sources */, 332 | ); 333 | runOnlyForDeploymentPostprocessing = 0; 334 | }; 335 | CDC01B8B1E5CA42000F6F3E2 /* Sources */ = { 336 | isa = PBXSourcesBuildPhase; 337 | buildActionMask = 2147483647; 338 | files = ( 339 | CDC722B41F72599F0077084B /* NSObject+KMNavigationBarTransition.m in Sources */, 340 | CDC01BA41E5CA48F00F6F3E2 /* KMWeakObjectContainer.m in Sources */, 341 | CDC722AE1F7257EE0077084B /* UINavigationBar+KMNavigationBarTransition.m in Sources */, 342 | CDC01BA61E5CA49300F6F3E2 /* KMSwizzle.m in Sources */, 343 | CDC01BA71E5CA67A00F6F3E2 /* UINavigationController+KMNavigationBarTransition.m in Sources */, 344 | CDC01BA21E5CA48B00F6F3E2 /* UIViewController+KMNavigationBarTransition.m in Sources */, 345 | CDE74D821F7A457C003052BE /* UIScrollView+KMNavigationBarTransition.m in Sources */, 346 | ); 347 | runOnlyForDeploymentPostprocessing = 0; 348 | }; 349 | /* End PBXSourcesBuildPhase section */ 350 | 351 | /* Begin PBXTargetDependency section */ 352 | CDC01B961E5CA42000F6F3E2 /* PBXTargetDependency */ = { 353 | isa = PBXTargetDependency; 354 | target = CDC01B8F1E5CA42000F6F3E2 /* KMNavigationBarTransition */; 355 | targetProxy = CDC01B951E5CA42000F6F3E2 /* PBXContainerItemProxy */; 356 | }; 357 | /* End PBXTargetDependency section */ 358 | 359 | /* Begin PBXVariantGroup section */ 360 | CDA372861C39089200E39A6D /* Main.storyboard */ = { 361 | isa = PBXVariantGroup; 362 | children = ( 363 | CDA372871C39089200E39A6D /* Base */, 364 | ); 365 | name = Main.storyboard; 366 | sourceTree = ""; 367 | }; 368 | CDA3728B1C3908A000E39A6D /* LaunchScreen.storyboard */ = { 369 | isa = PBXVariantGroup; 370 | children = ( 371 | CDA3728C1C3908A000E39A6D /* Base */, 372 | ); 373 | name = LaunchScreen.storyboard; 374 | sourceTree = ""; 375 | }; 376 | /* End PBXVariantGroup section */ 377 | 378 | /* Begin XCBuildConfiguration section */ 379 | CDA3727F1C3907CE00E39A6D /* Debug */ = { 380 | isa = XCBuildConfiguration; 381 | buildSettings = { 382 | ALWAYS_SEARCH_USER_PATHS = NO; 383 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 384 | CLANG_CXX_LIBRARY = "libc++"; 385 | CLANG_ENABLE_MODULES = YES; 386 | CLANG_ENABLE_OBJC_ARC = YES; 387 | CLANG_WARN_BOOL_CONVERSION = YES; 388 | CLANG_WARN_CONSTANT_CONVERSION = YES; 389 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 390 | CLANG_WARN_EMPTY_BODY = YES; 391 | CLANG_WARN_ENUM_CONVERSION = YES; 392 | CLANG_WARN_INFINITE_RECURSION = YES; 393 | CLANG_WARN_INT_CONVERSION = YES; 394 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 395 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 396 | CLANG_WARN_UNREACHABLE_CODE = YES; 397 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 398 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 399 | COPY_PHASE_STRIP = NO; 400 | DEBUG_INFORMATION_FORMAT = dwarf; 401 | ENABLE_STRICT_OBJC_MSGSEND = YES; 402 | ENABLE_TESTABILITY = YES; 403 | GCC_C_LANGUAGE_STANDARD = gnu99; 404 | GCC_DYNAMIC_NO_PIC = NO; 405 | GCC_NO_COMMON_BLOCKS = YES; 406 | GCC_OPTIMIZATION_LEVEL = 0; 407 | GCC_PREPROCESSOR_DEFINITIONS = ( 408 | "DEBUG=1", 409 | "$(inherited)", 410 | ); 411 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 412 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 413 | GCC_WARN_UNDECLARED_SELECTOR = YES; 414 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 415 | GCC_WARN_UNUSED_FUNCTION = YES; 416 | GCC_WARN_UNUSED_VARIABLE = YES; 417 | IPHONEOS_DEPLOYMENT_TARGET = 9.0; 418 | MTL_ENABLE_DEBUG_INFO = YES; 419 | ONLY_ACTIVE_ARCH = YES; 420 | SDKROOT = iphoneos; 421 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 422 | SWIFT_VERSION = 4.0; 423 | TARGETED_DEVICE_FAMILY = "1,2"; 424 | }; 425 | name = Debug; 426 | }; 427 | CDA372801C3907CE00E39A6D /* Release */ = { 428 | isa = XCBuildConfiguration; 429 | buildSettings = { 430 | ALWAYS_SEARCH_USER_PATHS = NO; 431 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 432 | CLANG_CXX_LIBRARY = "libc++"; 433 | CLANG_ENABLE_MODULES = YES; 434 | CLANG_ENABLE_OBJC_ARC = YES; 435 | CLANG_WARN_BOOL_CONVERSION = YES; 436 | CLANG_WARN_CONSTANT_CONVERSION = YES; 437 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 438 | CLANG_WARN_EMPTY_BODY = YES; 439 | CLANG_WARN_ENUM_CONVERSION = YES; 440 | CLANG_WARN_INFINITE_RECURSION = YES; 441 | CLANG_WARN_INT_CONVERSION = YES; 442 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 443 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 444 | CLANG_WARN_UNREACHABLE_CODE = YES; 445 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 446 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 447 | COPY_PHASE_STRIP = NO; 448 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 449 | ENABLE_NS_ASSERTIONS = NO; 450 | ENABLE_STRICT_OBJC_MSGSEND = YES; 451 | GCC_C_LANGUAGE_STANDARD = gnu99; 452 | GCC_NO_COMMON_BLOCKS = YES; 453 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 454 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 455 | GCC_WARN_UNDECLARED_SELECTOR = YES; 456 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 457 | GCC_WARN_UNUSED_FUNCTION = YES; 458 | GCC_WARN_UNUSED_VARIABLE = YES; 459 | IPHONEOS_DEPLOYMENT_TARGET = 9.0; 460 | MTL_ENABLE_DEBUG_INFO = NO; 461 | SDKROOT = iphoneos; 462 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; 463 | SWIFT_VERSION = 4.0; 464 | TARGETED_DEVICE_FAMILY = "1,2"; 465 | VALIDATE_PRODUCT = YES; 466 | }; 467 | name = Release; 468 | }; 469 | CDA372821C3907CE00E39A6D /* Debug */ = { 470 | isa = XCBuildConfiguration; 471 | buildSettings = { 472 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 473 | INFOPLIST_FILE = "$(SRCROOT)/Example/Info.plist"; 474 | IPHONEOS_DEPLOYMENT_TARGET = 9.0; 475 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 476 | PRODUCT_BUNDLE_IDENTIFIER = "com.mo.KMNavigationBarTransition-Example"; 477 | PRODUCT_NAME = "$(TARGET_NAME)"; 478 | SWIFT_VERSION = 4.0; 479 | }; 480 | name = Debug; 481 | }; 482 | CDA372831C3907CE00E39A6D /* Release */ = { 483 | isa = XCBuildConfiguration; 484 | buildSettings = { 485 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 486 | INFOPLIST_FILE = "$(SRCROOT)/Example/Info.plist"; 487 | IPHONEOS_DEPLOYMENT_TARGET = 9.0; 488 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 489 | PRODUCT_BUNDLE_IDENTIFIER = "com.mo.KMNavigationBarTransition-Example"; 490 | PRODUCT_NAME = "$(TARGET_NAME)"; 491 | SWIFT_VERSION = 4.0; 492 | }; 493 | name = Release; 494 | }; 495 | CDC01B9A1E5CA42000F6F3E2 /* Debug */ = { 496 | isa = XCBuildConfiguration; 497 | buildSettings = { 498 | CLANG_ANALYZER_NONNULL = YES; 499 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 500 | CLANG_WARN_INFINITE_RECURSION = YES; 501 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 502 | CODE_SIGN_IDENTITY = ""; 503 | CURRENT_PROJECT_VERSION = 1; 504 | DEFINES_MODULE = YES; 505 | DYLIB_COMPATIBILITY_VERSION = 1; 506 | DYLIB_CURRENT_VERSION = 1; 507 | DYLIB_INSTALL_NAME_BASE = "@rpath"; 508 | INFOPLIST_FILE = KMNavigationBarTransition/Info.plist; 509 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; 510 | IPHONEOS_DEPLOYMENT_TARGET = 9.0; 511 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 512 | PRODUCT_BUNDLE_IDENTIFIER = com.mo.KMNavigationBarTransition; 513 | PRODUCT_NAME = "$(TARGET_NAME)"; 514 | SKIP_INSTALL = YES; 515 | VERSIONING_SYSTEM = "apple-generic"; 516 | VERSION_INFO_PREFIX = ""; 517 | }; 518 | name = Debug; 519 | }; 520 | CDC01B9B1E5CA42000F6F3E2 /* Release */ = { 521 | isa = XCBuildConfiguration; 522 | buildSettings = { 523 | CLANG_ANALYZER_NONNULL = YES; 524 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 525 | CLANG_WARN_INFINITE_RECURSION = YES; 526 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 527 | CODE_SIGN_IDENTITY = ""; 528 | CURRENT_PROJECT_VERSION = 1; 529 | DEFINES_MODULE = YES; 530 | DYLIB_COMPATIBILITY_VERSION = 1; 531 | DYLIB_CURRENT_VERSION = 1; 532 | DYLIB_INSTALL_NAME_BASE = "@rpath"; 533 | INFOPLIST_FILE = KMNavigationBarTransition/Info.plist; 534 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; 535 | IPHONEOS_DEPLOYMENT_TARGET = 9.0; 536 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 537 | PRODUCT_BUNDLE_IDENTIFIER = com.mo.KMNavigationBarTransition; 538 | PRODUCT_NAME = "$(TARGET_NAME)"; 539 | SKIP_INSTALL = YES; 540 | VERSIONING_SYSTEM = "apple-generic"; 541 | VERSION_INFO_PREFIX = ""; 542 | }; 543 | name = Release; 544 | }; 545 | /* End XCBuildConfiguration section */ 546 | 547 | /* Begin XCConfigurationList section */ 548 | CDA3726A1C3907CE00E39A6D /* Build configuration list for PBXProject "KMNavigationBarTransition" */ = { 549 | isa = XCConfigurationList; 550 | buildConfigurations = ( 551 | CDA3727F1C3907CE00E39A6D /* Debug */, 552 | CDA372801C3907CE00E39A6D /* Release */, 553 | ); 554 | defaultConfigurationIsVisible = 0; 555 | defaultConfigurationName = Release; 556 | }; 557 | CDA372811C3907CE00E39A6D /* Build configuration list for PBXNativeTarget "KMNavigationBarTransition-Example" */ = { 558 | isa = XCConfigurationList; 559 | buildConfigurations = ( 560 | CDA372821C3907CE00E39A6D /* Debug */, 561 | CDA372831C3907CE00E39A6D /* Release */, 562 | ); 563 | defaultConfigurationIsVisible = 0; 564 | defaultConfigurationName = Release; 565 | }; 566 | CDC01B991E5CA42000F6F3E2 /* Build configuration list for PBXNativeTarget "KMNavigationBarTransition" */ = { 567 | isa = XCConfigurationList; 568 | buildConfigurations = ( 569 | CDC01B9A1E5CA42000F6F3E2 /* Debug */, 570 | CDC01B9B1E5CA42000F6F3E2 /* Release */, 571 | ); 572 | defaultConfigurationIsVisible = 0; 573 | defaultConfigurationName = Release; 574 | }; 575 | /* End XCConfigurationList section */ 576 | }; 577 | rootObject = CDA372671C3907CE00E39A6D /* Project object */; 578 | } 579 | -------------------------------------------------------------------------------- /KMNavigationBarTransition.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /KMNavigationBarTransition.xcodeproj/xcshareddata/xcschemes/KMNavigationBarTransition-Example.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 43 | 45 | 51 | 52 | 53 | 54 | 60 | 62 | 68 | 69 | 70 | 71 | 73 | 74 | 77 | 78 | 79 | -------------------------------------------------------------------------------- /KMNavigationBarTransition.xcodeproj/xcshareddata/xcschemes/KMNavigationBarTransition.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 43 | 44 | 50 | 51 | 52 | 53 | 59 | 60 | 66 | 67 | 68 | 69 | 71 | 72 | 75 | 76 | 77 | -------------------------------------------------------------------------------- /KMNavigationBarTransition/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 19 | CFBundleVersion 20 | $(CURRENT_PROJECT_VERSION) 21 | NSPrincipalClass 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /KMNavigationBarTransition/KMNavigationBarTransition.h: -------------------------------------------------------------------------------- 1 | // 2 | // KMNavigationBarTransition.h 3 | // 4 | // Copyright (c) 2017 Zhouqi Mo (https://github.com/MoZhouqi) 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in 14 | // all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | // THE SOFTWARE. 23 | 24 | #import 25 | 26 | //! Project version number for KMNavigationBarTransition. 27 | FOUNDATION_EXPORT double KMNavigationBarTransitionVersionNumber; 28 | 29 | //! Project version string for KMNavigationBarTransition. 30 | FOUNDATION_EXPORT const unsigned char KMNavigationBarTransitionVersionString[]; 31 | 32 | // In this header, you should import all the public headers of your framework using statements like #import 33 | 34 | #import 35 | -------------------------------------------------------------------------------- /KMNavigationBarTransition/KMSwizzle.h: -------------------------------------------------------------------------------- 1 | // 2 | // KMSwizzle.h 3 | // 4 | // Copyright (c) 2017 Zhouqi Mo (https://github.com/MoZhouqi) 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in 14 | // all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | // THE SOFTWARE. 23 | 24 | #import 25 | 26 | extern void KMSwizzleMethod(Class originalCls, SEL originalSelector, Class swizzledCls, SEL swizzledSelector); 27 | -------------------------------------------------------------------------------- /KMNavigationBarTransition/KMSwizzle.m: -------------------------------------------------------------------------------- 1 | // 2 | // KMSwizzle.m 3 | // 4 | // Copyright (c) 2017 Zhouqi Mo (https://github.com/MoZhouqi) 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in 14 | // all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | // THE SOFTWARE. 23 | 24 | #import "KMSwizzle.h" 25 | #import 26 | 27 | void KMSwizzleMethod(Class originalCls, SEL originalSelector, Class swizzledCls, SEL swizzledSelector) { 28 | Method originalMethod = class_getInstanceMethod(originalCls, originalSelector); 29 | Method swizzledMethod = class_getInstanceMethod(swizzledCls, swizzledSelector); 30 | 31 | BOOL didAddMethod = 32 | class_addMethod(originalCls, 33 | originalSelector, 34 | method_getImplementation(swizzledMethod), 35 | method_getTypeEncoding(swizzledMethod)); 36 | 37 | if (didAddMethod) { 38 | class_replaceMethod(originalCls, 39 | swizzledSelector, 40 | method_getImplementation(originalMethod), 41 | method_getTypeEncoding(originalMethod)); 42 | } else { 43 | method_exchangeImplementations(originalMethod, swizzledMethod); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /KMNavigationBarTransition/KMWeakObjectContainer.h: -------------------------------------------------------------------------------- 1 | // 2 | // KMWeakObjectContainer.h 3 | // 4 | // Copyright (c) 2017 Zhouqi Mo (https://github.com/MoZhouqi) 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in 14 | // all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | // THE SOFTWARE. 23 | 24 | #import 25 | 26 | extern void km_objc_setAssociatedWeakObject(id container, void *key, id value); 27 | extern id km_objc_getAssociatedWeakObject(id container, void *key); 28 | 29 | -------------------------------------------------------------------------------- /KMNavigationBarTransition/KMWeakObjectContainer.m: -------------------------------------------------------------------------------- 1 | // 2 | // KMWeakObjectContainer.m 3 | // 4 | // Copyright (c) 2017 Zhouqi Mo (https://github.com/MoZhouqi) 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in 14 | // all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | // THE SOFTWARE. 23 | 24 | #import "KMWeakObjectContainer.h" 25 | #import 26 | 27 | @interface KMWeakObjectContainer : NSObject 28 | @property (nonatomic, weak) id object; 29 | @end 30 | 31 | @implementation KMWeakObjectContainer 32 | 33 | void km_objc_setAssociatedWeakObject(id container, void *key, id value) 34 | { 35 | KMWeakObjectContainer *wrapper = [[KMWeakObjectContainer alloc] init]; 36 | wrapper.object = value; 37 | objc_setAssociatedObject(container, key, wrapper, OBJC_ASSOCIATION_RETAIN_NONATOMIC); 38 | } 39 | 40 | id km_objc_getAssociatedWeakObject(id container, void *key) 41 | { 42 | return [(KMWeakObjectContainer *)objc_getAssociatedObject(container, key) object]; 43 | } 44 | 45 | @end 46 | -------------------------------------------------------------------------------- /KMNavigationBarTransition/NSObject+KMNavigationBarTransition.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSObject+KMNavigationBarTransition.h 3 | // 4 | // Copyright (c) 2017 Zhouqi Mo (https://github.com/MoZhouqi) 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in 14 | // all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | // THE SOFTWARE. 23 | 24 | #import 25 | 26 | @interface NSObject (KMNavigationBarTransition) 27 | 28 | @end 29 | -------------------------------------------------------------------------------- /KMNavigationBarTransition/NSObject+KMNavigationBarTransition.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSObject+KMNavigationBarTransition.m 3 | // 4 | // Copyright (c) 2017 Zhouqi Mo (https://github.com/MoZhouqi) 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in 14 | // all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | // THE SOFTWARE. 23 | 24 | #import "NSObject+KMNavigationBarTransition.h" 25 | #import "UINavigationController+KMNavigationBarTransition_internal.h" 26 | #import "UINavigationBar+KMNavigationBarTransition_internal.h" 27 | #import 28 | #import "KMSwizzle.h" 29 | 30 | @implementation NSObject (KMNavigationBarTransition) 31 | 32 | + (void)load { 33 | static dispatch_once_t onceToken; 34 | dispatch_once(&onceToken, ^{ 35 | KMSwizzleMethod(objc_getClass("_UIBarBackground"), 36 | @selector(setHidden:), 37 | [self class], 38 | @selector(km_setHidden:)); 39 | }); 40 | } 41 | 42 | - (void)km_setHidden:(BOOL)hidden { 43 | UIResponder *responder = (UIResponder *)self; 44 | while (responder) { 45 | if ([responder isKindOfClass:[UINavigationBar class]] && ((UINavigationBar *)responder).km_isFakeBar) { 46 | return; 47 | } 48 | if ([responder isKindOfClass:[UINavigationController class]]) { 49 | [self km_setHidden:((UINavigationController *)responder).km_backgroundViewHidden]; 50 | return; 51 | } 52 | responder = responder.nextResponder; 53 | } 54 | [self km_setHidden:hidden]; 55 | } 56 | 57 | @end 58 | 59 | 60 | 61 | 62 | 63 | -------------------------------------------------------------------------------- /KMNavigationBarTransition/UINavigationBar+KMNavigationBarTransition.h: -------------------------------------------------------------------------------- 1 | // 2 | // UINavigationBar+KMNavigationBarTransition.h 3 | // 4 | // Copyright (c) 2017 Zhouqi Mo (https://github.com/MoZhouqi) 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in 14 | // all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | // THE SOFTWARE. 23 | 24 | #import 25 | 26 | @interface UINavigationBar (KMNavigationBarTransition) 27 | 28 | @end 29 | -------------------------------------------------------------------------------- /KMNavigationBarTransition/UINavigationBar+KMNavigationBarTransition.m: -------------------------------------------------------------------------------- 1 | // 2 | // UINavigationBar+KMNavigationBarTransition.m 3 | // 4 | // Copyright (c) 2017 Zhouqi Mo (https://github.com/MoZhouqi) 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in 14 | // all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | // THE SOFTWARE. 23 | 24 | #import "UINavigationBar+KMNavigationBarTransition.h" 25 | #import 26 | #import "KMSwizzle.h" 27 | 28 | @implementation UINavigationBar (KMNavigationBarTransition) 29 | 30 | #ifdef __IPHONE_11_0 31 | + (void)load { 32 | static dispatch_once_t onceToken; 33 | dispatch_once(&onceToken, ^{ 34 | KMSwizzleMethod([self class], 35 | @selector(layoutSubviews), 36 | [self class], 37 | @selector(km_layoutSubviews)); 38 | }); 39 | } 40 | #endif 41 | 42 | - (void)km_layoutSubviews { 43 | [self km_layoutSubviews]; 44 | UIView *backgroundView = [self valueForKey:@"_backgroundView"]; 45 | CGRect frame = backgroundView.frame; 46 | frame.size.height = self.frame.size.height + fabs(frame.origin.y); 47 | backgroundView.frame = frame; 48 | } 49 | 50 | - (BOOL)km_isFakeBar { 51 | return [objc_getAssociatedObject(self, _cmd) boolValue]; 52 | } 53 | 54 | - (void)setKm_isFakeBar:(BOOL)hidden { 55 | objc_setAssociatedObject(self, @selector(km_isFakeBar), @(hidden), OBJC_ASSOCIATION_RETAIN_NONATOMIC); 56 | } 57 | 58 | @end 59 | -------------------------------------------------------------------------------- /KMNavigationBarTransition/UINavigationBar+KMNavigationBarTransition_internal.h: -------------------------------------------------------------------------------- 1 | // 2 | // UINavigationBar+KMNavigationBarTransition_internal.h 3 | // 4 | // Copyright (c) 2017 Zhouqi Mo (https://github.com/MoZhouqi) 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in 14 | // all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | // THE SOFTWARE. 23 | 24 | #import 25 | 26 | @interface UINavigationBar (KMNavigationBarTransition_internal) 27 | 28 | @property (nonatomic, assign) BOOL km_isFakeBar; 29 | 30 | @end 31 | -------------------------------------------------------------------------------- /KMNavigationBarTransition/UINavigationController+KMNavigationBarTransition.h: -------------------------------------------------------------------------------- 1 | // 2 | // UINavigationController+KMNavigationBarTransition.h 3 | // 4 | // Copyright (c) 2017 Zhouqi Mo (https://github.com/MoZhouqi) 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in 14 | // all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | // THE SOFTWARE. 23 | 24 | #import 25 | 26 | @interface UINavigationController (KMNavigationBarTransition) 27 | 28 | // By default this is white, it is related to issue with transparent navigationBar 29 | - (UIColor *)km_containerViewBackgroundColor; 30 | 31 | @end 32 | -------------------------------------------------------------------------------- /KMNavigationBarTransition/UINavigationController+KMNavigationBarTransition.m: -------------------------------------------------------------------------------- 1 | // 2 | // UINavigationController+KMNavigationBarTransition.m 3 | // 4 | // Copyright (c) 2017 Zhouqi Mo (https://github.com/MoZhouqi) 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in 14 | // all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | // THE SOFTWARE. 23 | 24 | #import "UINavigationController+KMNavigationBarTransition.h" 25 | #import "UINavigationController+KMNavigationBarTransition_internal.h" 26 | #import "UIViewController+KMNavigationBarTransition.h" 27 | #import "UIViewController+KMNavigationBarTransition_internal.h" 28 | #import "KMWeakObjectContainer.h" 29 | #import 30 | #import "KMSwizzle.h" 31 | 32 | @implementation UINavigationController (KMNavigationBarTransition) 33 | 34 | + (void)load { 35 | static dispatch_once_t onceToken; 36 | dispatch_once(&onceToken, ^{ 37 | KMSwizzleMethod([self class], 38 | @selector(pushViewController:animated:), 39 | [self class], 40 | @selector(km_pushViewController:animated:)); 41 | 42 | KMSwizzleMethod([self class], 43 | @selector(popViewControllerAnimated:), 44 | [self class], 45 | @selector(km_popViewControllerAnimated:)); 46 | 47 | KMSwizzleMethod([self class], 48 | @selector(popToViewController:animated:), 49 | [self class], 50 | @selector(km_popToViewController:animated:)); 51 | 52 | KMSwizzleMethod([self class], 53 | @selector(popToRootViewControllerAnimated:), 54 | [self class], 55 | @selector(km_popToRootViewControllerAnimated:)); 56 | 57 | KMSwizzleMethod([self class], 58 | @selector(setViewControllers:animated:), 59 | [self class], 60 | @selector(km_setViewControllers:animated:)); 61 | }); 62 | } 63 | 64 | - (UIColor *)km_containerViewBackgroundColor { 65 | return [UIColor whiteColor]; 66 | } 67 | 68 | - (void)km_pushViewController:(UIViewController *)viewController animated:(BOOL)animated { 69 | UIViewController *disappearingViewController = self.viewControllers.lastObject; 70 | if (!disappearingViewController) { 71 | return [self km_pushViewController:viewController animated:animated]; 72 | } 73 | if (!self.km_transitionContextToViewController || !disappearingViewController.km_transitionNavigationBar) { 74 | [disappearingViewController km_addTransitionNavigationBarIfNeeded]; 75 | } 76 | if (animated) { 77 | self.km_transitionContextToViewController = viewController; 78 | if (disappearingViewController.km_transitionNavigationBar) { 79 | disappearingViewController.navigationController.km_backgroundViewHidden = YES; 80 | } 81 | } 82 | return [self km_pushViewController:viewController animated:animated]; 83 | } 84 | 85 | - (UIViewController *)km_popViewControllerAnimated:(BOOL)animated { 86 | if (self.viewControllers.count < 2) { 87 | return [self km_popViewControllerAnimated:animated]; 88 | } 89 | UIViewController *disappearingViewController = self.viewControllers.lastObject; 90 | [disappearingViewController km_addTransitionNavigationBarIfNeeded]; 91 | UIViewController *appearingViewController = self.viewControllers[self.viewControllers.count - 2]; 92 | if (appearingViewController.km_transitionNavigationBar) { 93 | UINavigationBar *appearingNavigationBar = appearingViewController.km_transitionNavigationBar; 94 | if (@available(iOS 15, *)) { 95 | self.navigationBar.standardAppearance = appearingNavigationBar.standardAppearance; 96 | self.navigationBar.scrollEdgeAppearance = appearingNavigationBar.scrollEdgeAppearance; 97 | } else { 98 | self.navigationBar.barTintColor = appearingNavigationBar.barTintColor; 99 | [self.navigationBar setBackgroundImage:[appearingNavigationBar backgroundImageForBarMetrics:UIBarMetricsDefault] forBarMetrics:UIBarMetricsDefault]; 100 | self.navigationBar.shadowImage = appearingNavigationBar.shadowImage; 101 | } 102 | } 103 | if (animated) { 104 | disappearingViewController.navigationController.km_backgroundViewHidden = YES; 105 | } 106 | return [self km_popViewControllerAnimated:animated]; 107 | } 108 | 109 | - (NSArray *)km_popToViewController:(UIViewController *)viewController animated:(BOOL)animated { 110 | if (![self.viewControllers containsObject:viewController] || self.viewControllers.count < 2) { 111 | return [self km_popToViewController:viewController animated:animated]; 112 | } 113 | UIViewController *disappearingViewController = self.viewControllers.lastObject; 114 | [disappearingViewController km_addTransitionNavigationBarIfNeeded]; 115 | if (viewController.km_transitionNavigationBar) { 116 | UINavigationBar *appearingNavigationBar = viewController.km_transitionNavigationBar; 117 | if (@available(iOS 15, *)) { 118 | self.navigationBar.standardAppearance = appearingNavigationBar.standardAppearance; 119 | self.navigationBar.scrollEdgeAppearance = appearingNavigationBar.scrollEdgeAppearance; 120 | } else { 121 | self.navigationBar.barTintColor = appearingNavigationBar.barTintColor; 122 | [self.navigationBar setBackgroundImage:[appearingNavigationBar backgroundImageForBarMetrics:UIBarMetricsDefault] forBarMetrics:UIBarMetricsDefault]; 123 | self.navigationBar.shadowImage = appearingNavigationBar.shadowImage; 124 | } 125 | } 126 | if (animated) { 127 | disappearingViewController.navigationController.km_backgroundViewHidden = YES; 128 | } 129 | return [self km_popToViewController:viewController animated:animated]; 130 | } 131 | 132 | - (NSArray *)km_popToRootViewControllerAnimated:(BOOL)animated { 133 | if (self.viewControllers.count < 2) { 134 | return [self km_popToRootViewControllerAnimated:animated]; 135 | } 136 | UIViewController *disappearingViewController = self.viewControllers.lastObject; 137 | [disappearingViewController km_addTransitionNavigationBarIfNeeded]; 138 | UIViewController *rootViewController = self.viewControllers.firstObject; 139 | if (rootViewController.km_transitionNavigationBar) { 140 | UINavigationBar *appearingNavigationBar = rootViewController.km_transitionNavigationBar; 141 | if (@available(iOS 15, *)) { 142 | self.navigationBar.standardAppearance = appearingNavigationBar.standardAppearance; 143 | self.navigationBar.scrollEdgeAppearance = appearingNavigationBar.scrollEdgeAppearance; 144 | } else { 145 | self.navigationBar.barTintColor = appearingNavigationBar.barTintColor; 146 | [self.navigationBar setBackgroundImage:[appearingNavigationBar backgroundImageForBarMetrics:UIBarMetricsDefault] forBarMetrics:UIBarMetricsDefault]; 147 | self.navigationBar.shadowImage = appearingNavigationBar.shadowImage; 148 | } 149 | } 150 | if (animated) { 151 | disappearingViewController.navigationController.km_backgroundViewHidden = YES; 152 | } 153 | return [self km_popToRootViewControllerAnimated:animated]; 154 | } 155 | 156 | - (void)km_setViewControllers:(NSArray *)viewControllers animated:(BOOL)animated { 157 | UIViewController *disappearingViewController = self.viewControllers.lastObject; 158 | if (animated && disappearingViewController && ![disappearingViewController isEqual:viewControllers.lastObject]) { 159 | [disappearingViewController km_addTransitionNavigationBarIfNeeded]; 160 | if (disappearingViewController.km_transitionNavigationBar) { 161 | disappearingViewController.navigationController.km_backgroundViewHidden = YES; 162 | } 163 | } 164 | return [self km_setViewControllers:viewControllers animated:animated]; 165 | } 166 | 167 | - (BOOL)km_backgroundViewHidden { 168 | return [objc_getAssociatedObject(self, _cmd) boolValue]; 169 | } 170 | 171 | - (void)setKm_backgroundViewHidden:(BOOL)hidden { 172 | objc_setAssociatedObject(self, @selector(km_backgroundViewHidden), @(hidden), OBJC_ASSOCIATION_RETAIN_NONATOMIC); 173 | [[self.navigationBar valueForKey:@"_backgroundView"] 174 | setHidden:hidden]; 175 | } 176 | 177 | - (UIViewController *)km_transitionContextToViewController { 178 | return km_objc_getAssociatedWeakObject(self, _cmd); 179 | } 180 | 181 | - (void)setKm_transitionContextToViewController:(UIViewController *)viewController { 182 | km_objc_setAssociatedWeakObject(self, @selector(km_transitionContextToViewController), viewController); 183 | } 184 | 185 | @end 186 | -------------------------------------------------------------------------------- /KMNavigationBarTransition/UINavigationController+KMNavigationBarTransition_internal.h: -------------------------------------------------------------------------------- 1 | // 2 | // UINavigationController+KMNavigationBarTransition_internal.h 3 | // 4 | // Copyright (c) 2017 Zhouqi Mo (https://github.com/MoZhouqi) 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in 14 | // all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | // THE SOFTWARE. 23 | 24 | #import 25 | 26 | @interface UINavigationController (KMNavigationBarTransition_internal) 27 | 28 | @property (nonatomic, assign) BOOL km_backgroundViewHidden; 29 | @property (nonatomic, weak) UIViewController *km_transitionContextToViewController; 30 | 31 | @end 32 | 33 | -------------------------------------------------------------------------------- /KMNavigationBarTransition/UIScrollView+KMNavigationBarTransition.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIScrollView+KMNavigationBarTransition.h 3 | // 4 | // Copyright (c) 2017 Zhouqi Mo (https://github.com/MoZhouqi) 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in 14 | // all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | // THE SOFTWARE. 23 | 24 | #import 25 | 26 | @interface UIScrollView (KMNavigationBarTransition) 27 | 28 | @end 29 | -------------------------------------------------------------------------------- /KMNavigationBarTransition/UIScrollView+KMNavigationBarTransition.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIScrollView+KMNavigationBarTransition.m 3 | // 4 | // Copyright (c) 2017 Zhouqi Mo (https://github.com/MoZhouqi) 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in 14 | // all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | // THE SOFTWARE. 23 | 24 | #import "UIScrollView+KMNavigationBarTransition.h" 25 | #import "UIScrollView+KMNavigationBarTransition_internal.h" 26 | #import 27 | #import "KMSwizzle.h" 28 | 29 | @implementation UIScrollView (KMNavigationBarTransition) 30 | 31 | #ifdef __IPHONE_11_0 32 | - (UIScrollViewContentInsetAdjustmentBehavior)km_originalContentInsetAdjustmentBehavior { 33 | return [objc_getAssociatedObject(self, _cmd) integerValue]; 34 | } 35 | 36 | - (void)setKm_originalContentInsetAdjustmentBehavior:(UIScrollViewContentInsetAdjustmentBehavior)contentInsetAdjustmentBehavior { 37 | objc_setAssociatedObject(self, @selector(km_originalContentInsetAdjustmentBehavior), @(contentInsetAdjustmentBehavior), OBJC_ASSOCIATION_RETAIN_NONATOMIC); 38 | } 39 | 40 | - (BOOL)km_shouldRestoreContentInsetAdjustmentBehavior { 41 | return [objc_getAssociatedObject(self, _cmd) boolValue]; 42 | } 43 | 44 | - (void)setKm_shouldRestoreContentInsetAdjustmentBehavior:(BOOL)isShould { 45 | objc_setAssociatedObject(self, @selector(km_shouldRestoreContentInsetAdjustmentBehavior), @(isShould), OBJC_ASSOCIATION_RETAIN_NONATOMIC); 46 | } 47 | #endif 48 | 49 | @end 50 | -------------------------------------------------------------------------------- /KMNavigationBarTransition/UIScrollView+KMNavigationBarTransition_internal.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIScrollView+KMNavigationBarTransition_internal.h 3 | // 4 | // Copyright (c) 2017 Zhouqi Mo (https://github.com/MoZhouqi) 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in 14 | // all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | // THE SOFTWARE. 23 | 24 | #import 25 | 26 | @interface UIScrollView (KMNavigationBarTransition_internal) 27 | 28 | #ifdef __IPHONE_11_0 29 | @property (nonatomic, assign) UIScrollViewContentInsetAdjustmentBehavior km_originalContentInsetAdjustmentBehavior NS_AVAILABLE_IOS(11_0); 30 | @property (nonatomic, assign) BOOL km_shouldRestoreContentInsetAdjustmentBehavior NS_AVAILABLE_IOS(11_0); 31 | #endif 32 | 33 | @end 34 | -------------------------------------------------------------------------------- /KMNavigationBarTransition/UIViewController+KMNavigationBarTransition.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIViewController+KMNavigationBarTransition.h 3 | // 4 | // Copyright (c) 2017 Zhouqi Mo (https://github.com/MoZhouqi) 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in 14 | // all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | // THE SOFTWARE. 23 | 24 | #import 25 | 26 | @interface UIViewController (KMNavigationBarTransition) 27 | 28 | @property (nonatomic, weak) UIScrollView *km_scrollView; 29 | 30 | @end 31 | -------------------------------------------------------------------------------- /KMNavigationBarTransition/UIViewController+KMNavigationBarTransition.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIViewController+KMNavigationBarTransition.m 3 | // 4 | // Copyright (c) 2017 Zhouqi Mo (https://github.com/MoZhouqi) 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in 14 | // all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | // THE SOFTWARE. 23 | 24 | #import "UIViewController+KMNavigationBarTransition.h" 25 | #import "UINavigationController+KMNavigationBarTransition.h" 26 | #import "UINavigationController+KMNavigationBarTransition_internal.h" 27 | #import "UINavigationBar+KMNavigationBarTransition_internal.h" 28 | #import "UIScrollView+KMNavigationBarTransition_internal.h" 29 | #import "KMWeakObjectContainer.h" 30 | #import 31 | #import "KMSwizzle.h" 32 | 33 | @implementation UIViewController (KMNavigationBarTransition) 34 | 35 | + (void)load { 36 | static dispatch_once_t onceToken; 37 | dispatch_once(&onceToken, ^{ 38 | KMSwizzleMethod([self class], 39 | @selector(viewWillLayoutSubviews), 40 | [self class], 41 | @selector(km_viewWillLayoutSubviews)); 42 | 43 | KMSwizzleMethod([self class], 44 | @selector(viewWillAppear:), 45 | [self class], 46 | @selector(km_viewWillAppear:)); 47 | 48 | KMSwizzleMethod([self class], 49 | @selector(viewDidAppear:), 50 | [self class], 51 | @selector(km_viewDidAppear:)); 52 | }); 53 | } 54 | 55 | - (void)km_viewWillAppear:(BOOL)animated { 56 | [self km_viewWillAppear:animated]; 57 | id tc = self.transitionCoordinator; 58 | UIViewController *toViewController = [tc viewControllerForKey:UITransitionContextToViewControllerKey]; 59 | 60 | if ([self isEqual:self.navigationController.viewControllers.lastObject] && [toViewController isEqual:self] && tc.presentationStyle == UIModalPresentationNone) { 61 | [self km_adjustScrollViewContentInsetAdjustmentBehavior]; 62 | dispatch_async(dispatch_get_main_queue(), ^{ 63 | if (self.navigationController.navigationBarHidden) { 64 | [self km_restoreScrollViewContentInsetAdjustmentBehaviorIfNeeded]; 65 | } 66 | }); 67 | } 68 | } 69 | 70 | - (void)km_viewDidAppear:(BOOL)animated { 71 | [self km_restoreScrollViewContentInsetAdjustmentBehaviorIfNeeded]; 72 | UIViewController *transitionViewController = self.navigationController.km_transitionContextToViewController; 73 | if (self.km_transitionNavigationBar) { 74 | if (@available(iOS 15, *)) { 75 | self.navigationController.navigationBar.standardAppearance = self.km_transitionNavigationBar.standardAppearance; 76 | self.navigationController.navigationBar.scrollEdgeAppearance = self.km_transitionNavigationBar.scrollEdgeAppearance; 77 | } else { 78 | self.navigationController.navigationBar.barTintColor = self.km_transitionNavigationBar.barTintColor; 79 | [self.navigationController.navigationBar setBackgroundImage:[self.km_transitionNavigationBar backgroundImageForBarMetrics:UIBarMetricsDefault] forBarMetrics:UIBarMetricsDefault]; 80 | [self.navigationController.navigationBar setShadowImage:self.km_transitionNavigationBar.shadowImage]; 81 | } 82 | if (!transitionViewController || [transitionViewController isEqual:self]) { 83 | [self.km_transitionNavigationBar removeFromSuperview]; 84 | self.km_transitionNavigationBar = nil; 85 | } 86 | } 87 | if ([transitionViewController isEqual:self]) { 88 | self.navigationController.km_transitionContextToViewController = nil; 89 | } 90 | self.navigationController.km_backgroundViewHidden = NO; 91 | [self km_viewDidAppear:animated]; 92 | } 93 | 94 | - (void)km_viewWillLayoutSubviews { 95 | id tc = self.transitionCoordinator; 96 | UIViewController *fromViewController = [tc viewControllerForKey:UITransitionContextFromViewControllerKey]; 97 | UIViewController *toViewController = [tc viewControllerForKey:UITransitionContextToViewControllerKey]; 98 | 99 | if ([self isEqual:self.navigationController.viewControllers.lastObject] && [toViewController isEqual:self] && tc.presentationStyle == UIModalPresentationNone) { 100 | if (self.navigationController.navigationBar.translucent) { 101 | [tc containerView].backgroundColor = [self.navigationController km_containerViewBackgroundColor]; 102 | } 103 | fromViewController.view.clipsToBounds = NO; 104 | toViewController.view.clipsToBounds = NO; 105 | if (!self.km_transitionNavigationBar) { 106 | [self km_addTransitionNavigationBarIfNeeded]; 107 | self.navigationController.km_backgroundViewHidden = YES; 108 | } 109 | [self km_resizeTransitionNavigationBarFrame]; 110 | } 111 | if (self.km_transitionNavigationBar) { 112 | [self.view bringSubviewToFront:self.km_transitionNavigationBar]; 113 | } 114 | [self km_viewWillLayoutSubviews]; 115 | } 116 | 117 | - (void)km_resizeTransitionNavigationBarFrame { 118 | if (!self.view.window) { 119 | return; 120 | } 121 | UIView *backgroundView = [self.navigationController.navigationBar valueForKey:@"_backgroundView"]; 122 | CGRect rect = [self.navigationController.navigationBar convertRect:backgroundView.frame toView:self.view]; 123 | self.km_transitionNavigationBar.frame = rect; 124 | } 125 | 126 | - (void)km_addTransitionNavigationBarIfNeeded { 127 | if (!self.isViewLoaded || !self.view.window) { 128 | return; 129 | } 130 | if (!self.navigationController.navigationBar) { 131 | return; 132 | } 133 | [self km_adjustScrollViewContentOffsetIfNeeded]; 134 | UINavigationBar *bar = [[UINavigationBar alloc] init]; 135 | bar.km_isFakeBar = YES; 136 | if (@available(iOS 14, *)) { 137 | bar.items = @[[UINavigationItem new]]; // fix Apple's bug in iOS 14 138 | } 139 | bar.barStyle = self.navigationController.navigationBar.barStyle; 140 | if (bar.translucent != self.navigationController.navigationBar.translucent) { 141 | bar.translucent = self.navigationController.navigationBar.translucent; 142 | } 143 | if (@available(iOS 15, *)) { 144 | bar.standardAppearance = self.navigationController.navigationBar.standardAppearance; 145 | bar.scrollEdgeAppearance = self.navigationController.navigationBar.scrollEdgeAppearance; 146 | } else { 147 | bar.barTintColor = self.navigationController.navigationBar.barTintColor; 148 | [bar setBackgroundImage:[self.navigationController.navigationBar backgroundImageForBarMetrics:UIBarMetricsDefault] forBarMetrics:UIBarMetricsDefault]; 149 | bar.shadowImage = self.navigationController.navigationBar.shadowImage; 150 | } 151 | [self.km_transitionNavigationBar removeFromSuperview]; 152 | self.km_transitionNavigationBar = bar; 153 | [self km_resizeTransitionNavigationBarFrame]; 154 | if (!self.navigationController.navigationBarHidden && !self.navigationController.navigationBar.hidden) { 155 | [self.view addSubview:self.km_transitionNavigationBar]; 156 | } 157 | } 158 | 159 | - (void)km_adjustScrollViewContentOffsetIfNeeded { 160 | UIScrollView *scrollView = self.km_visibleScrollView; 161 | if (scrollView) { 162 | UIEdgeInsets contentInset; 163 | #ifdef __IPHONE_11_0 164 | if (@available(iOS 11.0, *)) { 165 | contentInset = scrollView.adjustedContentInset; 166 | } else { 167 | contentInset = scrollView.contentInset; 168 | } 169 | #else 170 | contentInset = scrollView.contentInset; 171 | #endif 172 | const CGFloat topContentOffsetY = -contentInset.top; 173 | const CGFloat bottomContentOffsetY = scrollView.contentSize.height - (CGRectGetHeight(scrollView.bounds) - contentInset.bottom); 174 | 175 | CGPoint adjustedContentOffset = scrollView.contentOffset; 176 | if (adjustedContentOffset.y > bottomContentOffsetY) { 177 | adjustedContentOffset.y = bottomContentOffsetY; 178 | } 179 | if (adjustedContentOffset.y < topContentOffsetY) { 180 | adjustedContentOffset.y = topContentOffsetY; 181 | } 182 | [scrollView setContentOffset:adjustedContentOffset animated:NO]; 183 | } 184 | } 185 | 186 | - (void)km_adjustScrollViewContentInsetAdjustmentBehavior { 187 | #ifdef __IPHONE_11_0 188 | if (self.navigationController.navigationBar.translucent) { 189 | return; 190 | } 191 | if (@available(iOS 11.0, *)) { 192 | UIScrollView *scrollView = self.km_visibleScrollView; 193 | if (scrollView) { 194 | UIScrollViewContentInsetAdjustmentBehavior contentInsetAdjustmentBehavior = scrollView.contentInsetAdjustmentBehavior; 195 | if (contentInsetAdjustmentBehavior != UIScrollViewContentInsetAdjustmentNever) { 196 | scrollView.km_originalContentInsetAdjustmentBehavior = contentInsetAdjustmentBehavior; 197 | scrollView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever; 198 | scrollView.km_shouldRestoreContentInsetAdjustmentBehavior = YES; 199 | } 200 | } 201 | } 202 | #endif 203 | } 204 | 205 | - (void)km_restoreScrollViewContentInsetAdjustmentBehaviorIfNeeded { 206 | #ifdef __IPHONE_11_0 207 | if (@available(iOS 11.0, *)) { 208 | UIScrollView *scrollView = self.km_visibleScrollView; 209 | if (scrollView) { 210 | if (scrollView.km_shouldRestoreContentInsetAdjustmentBehavior) { 211 | scrollView.contentInsetAdjustmentBehavior = scrollView.km_originalContentInsetAdjustmentBehavior; 212 | scrollView.km_shouldRestoreContentInsetAdjustmentBehavior = NO; 213 | } 214 | } 215 | } 216 | #endif 217 | } 218 | 219 | 220 | - (UINavigationBar *)km_transitionNavigationBar { 221 | return objc_getAssociatedObject(self, _cmd); 222 | } 223 | 224 | - (void)setKm_transitionNavigationBar:(UINavigationBar *)navigationBar { 225 | objc_setAssociatedObject(self, @selector(km_transitionNavigationBar), navigationBar, OBJC_ASSOCIATION_RETAIN_NONATOMIC); 226 | } 227 | 228 | - (UIScrollView *)km_scrollView { 229 | return km_objc_getAssociatedWeakObject(self, _cmd); 230 | } 231 | 232 | - (void)setKm_scrollView:(UIScrollView *)scrollView { 233 | km_objc_setAssociatedWeakObject(self, @selector(km_scrollView), scrollView); 234 | } 235 | 236 | - (UIScrollView *)km_visibleScrollView { 237 | UIScrollView *scrollView = self.km_scrollView; 238 | if (!scrollView && [self.view isKindOfClass:[UIScrollView class]]) { 239 | scrollView = (UIScrollView *)self.view; 240 | } 241 | return scrollView; 242 | } 243 | 244 | @end 245 | -------------------------------------------------------------------------------- /KMNavigationBarTransition/UIViewController+KMNavigationBarTransition_internal.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIViewController+KMNavigationBarTransition_internal.h 3 | // 4 | // Copyright (c) 2017 Zhouqi Mo (https://github.com/MoZhouqi) 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in 14 | // all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | // THE SOFTWARE. 23 | 24 | #import 25 | 26 | @interface UIViewController (KMNavigationBarTransition_internal) 27 | 28 | @property (nonatomic, strong) UINavigationBar *km_transitionNavigationBar; 29 | 30 | - (void)km_addTransitionNavigationBarIfNeeded; 31 | 32 | @end 33 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2017 Zhouqi Mo (https://github.com/MoZhouqi) 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. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | KMNavigationBarTransition [中文介绍](https://github.com/MoZhouqi/KMNavigationBarTransition/blob/master/README_CN.md) 2 | ============ 3 | 4 | A drop-in universal library helps you to manage the navigation bar styles and makes transition animations smooth between different navigation bar styles while pushing or popping a view controller for all orientations. And you don't need to write any line of code for it, it all happens automatically. 5 | 6 | ## Screenshots 7 | 8 | ### Now 9 | 10 | ![KMNavigationBarTransition](https://raw.githubusercontent.com/MoZhouqi/KMNavigationBarTransition/master/Screenshots/Now1.gif) 11 | ![KMNavigationBarTransition](https://raw.githubusercontent.com/MoZhouqi/KMNavigationBarTransition/master/Screenshots/Now2.gif) 12 | 13 | ### Before 14 | 15 | ![KMNavigationBarTransition](https://raw.githubusercontent.com/MoZhouqi/KMNavigationBarTransition/master/Screenshots/Before1.gif) 16 | ![KMNavigationBarTransition](https://raw.githubusercontent.com/MoZhouqi/KMNavigationBarTransition/master/Screenshots/Before2.gif) 17 | 18 | ## Introduction 19 | 20 | The design concept of the library is that what you only need to care about is the background style of the navigation bar in the *current* view controller, without handling the various background styles while pushing or popping. 21 | 22 | The library can capture the background style of the navigation bar in the disappearing view controller when pushing, and when you pop back to the view controller, the navigation bar will restore the previous style, so you don't need to consider the background style after popping. And you also don't need to consider it after pushing, because it is the view controller to be pushed that needs to be considered. 23 | 24 | ## Usage 25 | 26 | You don't need to import any header file when using this library, the library uses [Method Swizzling](http://nshipster.com/method-swizzling/) to achieve the effect. 27 | 28 | It is recommended to set the default background style of the navigation bar in the `viewDidLoad` method of the base view controller. When you need to change it, generally, you only need to do it in the `viewDidLoad` method of the *current* view controller, but if you need to support peek and pop on 3D Touch, you can do it in the `viewWillAppear:` method. 29 | 30 | The following are some suggestions to set the background style of the navigation bar, and you can see the Example for details. 31 | 32 | - There are two methods to set the background style of the navigation bar, `setBackgroundImage:forBarMetrics:` and `setBarTintColor:`. It is recommended to use the former, you can see [Known Issues](#known-issues) for the details. 33 | 34 | - It is better not to change the value of the `translucent` property arbitrarily after initialization, otherwise the interface layout would be prone to confusion. 35 | 36 | - When the value of the `translucent` property is `true`, you can use the following mehod to make the navigation bar transparent: 37 | 38 | ```swift 39 | navigationController?.navigationBar.setBackgroundImage(UIImage(), forBarMetrics: .Default) 40 | navigationController?.navigationBar.shadowImage = UIImage() // shadowImage is the 1px line 41 | ``` 42 | 43 | - You can change the alpha value of the background color of the navigaiton bar by changing the alpha value of the image in the `setBackgroundImage:forBarMetrics:` method. 44 | 45 | - You can use the following method to show or hide the navigation bar in `viewWillAppear:`: 46 | 47 | ```swift 48 | override func viewWillAppear(animated: Bool) { 49 | super.viewWillAppear(animated) 50 | navigationController?.setNavigationBarHidden(hidden, animated: animated) 51 | } 52 | ``` 53 | 54 | You'd better not do it in neither `viewWillDisappear:` nor other methods performing transitions, because it is not easy to manage. Again, what you only need to care about is the style of the navigation bar in the *current* view controller. 55 | 56 | Of course, you'd better not hide the navigaion bar, it might triggers some apple's bug with interactive pop gesture. 57 | 58 | ## Installation 59 | 60 | ### CocoaPods 61 | 62 | You can install the latest release version of CocoaPods with the following command: 63 | 64 | ```bash 65 | $ gem install cocoapods 66 | ``` 67 | 68 | Simply add the following line to your Podfile: 69 | 70 | ```ruby 71 | pod 'KMNavigationBarTransition' 72 | ``` 73 | 74 | Then, run the following command: 75 | 76 | ```bash 77 | $ pod install 78 | ``` 79 | 80 | ### Carthage 81 | 82 | [Carthage](https://github.com/Carthage/Carthage) is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks. 83 | 84 | You can install Carthage with [Homebrew](http://brew.sh/) using the following command: 85 | 86 | ```bash 87 | $ brew update 88 | $ brew install carthage 89 | ``` 90 | 91 | To integrate KMNavigationBarTransition into your Xcode project using Carthage, specify it in your `Cartfile`: 92 | 93 | ```ogdl 94 | github "MoZhouqi/KMNavigationBarTransition" 95 | ``` 96 | 97 | Run `carthage update` to build the framework and drag the built `KMNavigationBarTransition.framework` into your Xcode project. 98 | 99 | ## Requirements 100 | 101 | - iOS 7.0+ 102 | 103 | ## Known Issues 104 | 105 | On iOS 8.2 or below, if you set the value of the `translucent` property to `true` and set the `barTintColor` for the background color, and then change the `barTintColor`, the background color of the navigation bar will flash when the interactive transition is cancelled. 106 | 107 | To avoid this from happening, it is recommended to use `setBackgroundImage:forBarMetrics:` instead of `setBarTintColor:` to change the background color of the navigation bar. 108 | 109 | ## License 110 | 111 | KMNavigationBarTransition is released under the MIT license. See LICENSE for details. 112 | -------------------------------------------------------------------------------- /README_CN.md: -------------------------------------------------------------------------------- 1 | KMNavigationBarTransition 2 | ============ 3 | 4 | 一个用来统一管理导航栏转场以及当 push 或者 pop 的时候使动画效果更加顺滑的通用库,并且同时支持竖屏和横屏。你不用为这个库写一行代码,所有的改变都悄然发生。 5 | 6 | ## 效果图 7 | 8 | ### 现在 9 | 10 | ![KMNavigationBarTransition](https://raw.githubusercontent.com/MoZhouqi/KMNavigationBarTransition/master/Screenshots/Now1.gif) 11 | ![KMNavigationBarTransition](https://raw.githubusercontent.com/MoZhouqi/KMNavigationBarTransition/master/Screenshots/Now2.gif) 12 | 13 | ### 之前 14 | 15 | ![KMNavigationBarTransition](https://raw.githubusercontent.com/MoZhouqi/KMNavigationBarTransition/master/Screenshots/Before1.gif) 16 | ![KMNavigationBarTransition](https://raw.githubusercontent.com/MoZhouqi/KMNavigationBarTransition/master/Screenshots/Before2.gif) 17 | 18 | ## 介绍 19 | 20 | 本库的设计理念是使用者只用关心*当前* view controller 导航栏的背景样式,而不用在 push 或者 pop 的时候处理各种背景样式。 21 | 22 | 当 push 的时候本库会保存消失的 view controller 导航栏的背景样式,当 pop 回去后就会还原成以前的样式,因此你不用考虑 pop 后各种导航栏样式改变的情况。同时你也不必考虑 push 后的情况,因为这个是被 push 的 view controller 本身需要考虑的。 23 | 24 | ## 使用说明 25 | 26 | 使用本库时不用 import 任何头文件,全部通过 [Method Swizzling](http://nshipster.com/method-swizzling/) 在底层做了处理。 27 | 28 | 推荐在所有 view controller 基类的 `viewDidLoad` 里设置默认的导航栏背景样式,当需要改变时,一般也只需要在*当前* view controller 的 `viewDidLoad` 里去设置,但是如果你需要支持 3D Touch 的 peek 和 pop 手势,你可以在 `viewWillAppear:` 里去设置。 29 | 30 | 下面是一些设置导航栏背景样式的建议,具体的用法可以参见 Example。 31 | 32 | - 设置导航栏背景样式有两个方法,`setBackgroundImage:forBarMetrics:` 和 `setBarTintColor:`。推荐使用前者,具体原因参见[已知问题](#已知问题)。 33 | 34 | - `translucent` 这个属性的值在初始化后尽量不要随意修改,否则容易发生界面的布局错乱。 35 | 36 | - 当`translucent` 为 `true` 时,可以用以下方法使导航栏背景透明: 37 | 38 | ```swift 39 | navigationController?.navigationBar.setBackgroundImage(UIImage(), forBarMetrics: .Default) 40 | navigationController?.navigationBar.shadowImage = UIImage() // shadowImage 就是那根 1px 的细线 41 | ``` 42 | 43 | - 当需要改变导航栏背景色的透明度时,可以改变 `setBackgroundImage:forBarMetrics:` 中 image 的 alpha 值。 44 | 45 | - 如果需要显示或隐藏导航栏,一般只需要在 `viewWillAppear:` 里设置,代码如下: 46 | 47 | ```swift 48 | override func viewWillAppear(animated: Bool) { 49 | super.viewWillAppear(animated) 50 | navigationController?.setNavigationBarHidden(hidden, animated: animated) 51 | } 52 | ``` 53 | 54 | 最好不要在 `viewWillDisappear:` 或者其他发生跳转的方法里去设置,这样不容易管理。还是那句宗旨,你只需要关心*当前* view controller 导航栏的样式。 55 | 56 | 当然最好还是不要隐藏导航栏,因为和系统边缘右滑返回手势一起使用可能会触发一些苹果的 bug。 57 | 58 | ## 安装 59 | 60 | ### CocoaPods 61 | 62 | 你可以用以下命令来安装最新版的 CocoaPods: 63 | 64 | ```bash 65 | $ gem install cocoapods 66 | ``` 67 | 68 | 在 `podfile` 中添加以下代码: 69 | 70 | ```ruby 71 | pod 'KMNavigationBarTransition' 72 | ``` 73 | 74 | 然后在终端运行以下命令: 75 | 76 | ```bash 77 | $ pod install 78 | ``` 79 | 80 | ### Carthage 81 | 82 | Carthage 是一个去中心化的包管理器工具。 83 | 84 | 你可以通过 [Homebrew](http://brew.sh/) 用以下命令来安装 Carthage: 85 | 86 | ```bash 87 | $ brew update 88 | $ brew install carthage 89 | ``` 90 | 91 | 在 `Cartfile` 中添加以下代码: 92 | 93 | ```ogdl 94 | github "MoZhouqi/KMNavigationBarTransition" 95 | ``` 96 | 97 | 运行 `carthage update` 命令来编译 framework 并且把编译好的 `KMNavigationBarTransition.framework` 文件拖入到 Xcode 工程中。 98 | 99 | ## 基本要求 100 | 101 | - iOS 7.0+ 102 | 103 | ## 已知问题 104 | 105 | 在 iOS 8.2 或者之前的版本,如果导航栏的 `translucent` 值为 `true` 时,用 `barTintColor` 去设置导航栏的背景样式,然后改变 `barTintColor` 的颜色,那么当边缘左滑返回手势取消的时候导航栏的背景色会闪烁。 106 | 107 | 为了避免这种情况发生,推荐用 `setBackgroundImage:forBarMetrics:` 来改变导航栏的背景样式。 108 | 109 | ## 许可证 110 | 111 | KMNavigationBarTransition 是基于 MIT 许可证下发布的,详情请参见 LICENSE。 112 | -------------------------------------------------------------------------------- /Screenshots/Before1.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoZhouqi/KMNavigationBarTransition/8bdf3cc420e620c5bf2eba027187ec079df8cde3/Screenshots/Before1.gif -------------------------------------------------------------------------------- /Screenshots/Before2.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoZhouqi/KMNavigationBarTransition/8bdf3cc420e620c5bf2eba027187ec079df8cde3/Screenshots/Before2.gif -------------------------------------------------------------------------------- /Screenshots/Now1.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoZhouqi/KMNavigationBarTransition/8bdf3cc420e620c5bf2eba027187ec079df8cde3/Screenshots/Now1.gif -------------------------------------------------------------------------------- /Screenshots/Now2.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoZhouqi/KMNavigationBarTransition/8bdf3cc420e620c5bf2eba027187ec079df8cde3/Screenshots/Now2.gif --------------------------------------------------------------------------------