├── ColorAdapativeStatusBarExample.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ └── contents.xcworkspacedata └── xcuserdata │ └── simontseng.xcuserdatad │ └── xcschemes │ ├── ColorAdapativeStatusBarExample.xcscheme │ └── xcschememanagement.plist ├── ColorAdapativeStatusBarExample ├── AppDelegate.swift ├── Assets.xcassets │ └── AppIcon.appiconset │ │ └── Contents.json ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard ├── Flower.png ├── Info.plist ├── Leaf.png ├── Rock.png ├── Sky.png ├── Type.png └── ViewController.swift └── README.md /ColorAdapativeStatusBarExample.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | BB233BE41CE232CD00FABB0F /* README.md in Sources */ = {isa = PBXBuildFile; fileRef = BB233BE31CE232CD00FABB0F /* README.md */; }; 11 | BBFA870D1CE1D7FF00439E68 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = BBFA870C1CE1D7FF00439E68 /* AppDelegate.swift */; }; 12 | BBFA870F1CE1D7FF00439E68 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = BBFA870E1CE1D7FF00439E68 /* ViewController.swift */; }; 13 | BBFA87121CE1D7FF00439E68 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = BBFA87101CE1D7FF00439E68 /* Main.storyboard */; }; 14 | BBFA87141CE1D7FF00439E68 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = BBFA87131CE1D7FF00439E68 /* Assets.xcassets */; }; 15 | BBFA87171CE1D7FF00439E68 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = BBFA87151CE1D7FF00439E68 /* LaunchScreen.storyboard */; }; 16 | BBFA87231CE1D81B00439E68 /* Flower.png in Resources */ = {isa = PBXBuildFile; fileRef = BBFA871E1CE1D81B00439E68 /* Flower.png */; }; 17 | BBFA87241CE1D81B00439E68 /* Type.png in Resources */ = {isa = PBXBuildFile; fileRef = BBFA871F1CE1D81B00439E68 /* Type.png */; }; 18 | BBFA87251CE1D81B00439E68 /* Leaf.png in Resources */ = {isa = PBXBuildFile; fileRef = BBFA87201CE1D81B00439E68 /* Leaf.png */; }; 19 | BBFA87261CE1D81B00439E68 /* Rock.png in Resources */ = {isa = PBXBuildFile; fileRef = BBFA87211CE1D81B00439E68 /* Rock.png */; }; 20 | BBFA87271CE1D81B00439E68 /* Sky.png in Resources */ = {isa = PBXBuildFile; fileRef = BBFA87221CE1D81B00439E68 /* Sky.png */; }; 21 | /* End PBXBuildFile section */ 22 | 23 | /* Begin PBXFileReference section */ 24 | BB233BE31CE232CD00FABB0F /* README.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = ""; }; 25 | BBFA87091CE1D7FF00439E68 /* ColorAdapativeStatusBarExample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ColorAdapativeStatusBarExample.app; sourceTree = BUILT_PRODUCTS_DIR; }; 26 | BBFA870C1CE1D7FF00439E68 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 27 | BBFA870E1CE1D7FF00439E68 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; 28 | BBFA87111CE1D7FF00439E68 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 29 | BBFA87131CE1D7FF00439E68 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 30 | BBFA87161CE1D7FF00439E68 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 31 | BBFA87181CE1D7FF00439E68 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 32 | BBFA871E1CE1D81B00439E68 /* Flower.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Flower.png; sourceTree = ""; }; 33 | BBFA871F1CE1D81B00439E68 /* Type.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Type.png; sourceTree = ""; }; 34 | BBFA87201CE1D81B00439E68 /* Leaf.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Leaf.png; sourceTree = ""; }; 35 | BBFA87211CE1D81B00439E68 /* Rock.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Rock.png; sourceTree = ""; }; 36 | BBFA87221CE1D81B00439E68 /* Sky.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Sky.png; sourceTree = ""; }; 37 | /* End PBXFileReference section */ 38 | 39 | /* Begin PBXFrameworksBuildPhase section */ 40 | BBFA87061CE1D7FF00439E68 /* Frameworks */ = { 41 | isa = PBXFrameworksBuildPhase; 42 | buildActionMask = 2147483647; 43 | files = ( 44 | ); 45 | runOnlyForDeploymentPostprocessing = 0; 46 | }; 47 | /* End PBXFrameworksBuildPhase section */ 48 | 49 | /* Begin PBXGroup section */ 50 | BBFA87001CE1D7FF00439E68 = { 51 | isa = PBXGroup; 52 | children = ( 53 | BB233BE31CE232CD00FABB0F /* README.md */, 54 | BBFA870B1CE1D7FF00439E68 /* ColorAdapativeStatusBarExample */, 55 | BBFA870A1CE1D7FF00439E68 /* Products */, 56 | ); 57 | sourceTree = ""; 58 | }; 59 | BBFA870A1CE1D7FF00439E68 /* Products */ = { 60 | isa = PBXGroup; 61 | children = ( 62 | BBFA87091CE1D7FF00439E68 /* ColorAdapativeStatusBarExample.app */, 63 | ); 64 | name = Products; 65 | sourceTree = ""; 66 | }; 67 | BBFA870B1CE1D7FF00439E68 /* ColorAdapativeStatusBarExample */ = { 68 | isa = PBXGroup; 69 | children = ( 70 | BBFA870C1CE1D7FF00439E68 /* AppDelegate.swift */, 71 | BBFA870E1CE1D7FF00439E68 /* ViewController.swift */, 72 | BBFA871E1CE1D81B00439E68 /* Flower.png */, 73 | BBFA871F1CE1D81B00439E68 /* Type.png */, 74 | BBFA87201CE1D81B00439E68 /* Leaf.png */, 75 | BBFA87211CE1D81B00439E68 /* Rock.png */, 76 | BBFA87221CE1D81B00439E68 /* Sky.png */, 77 | BBFA87101CE1D7FF00439E68 /* Main.storyboard */, 78 | BBFA87131CE1D7FF00439E68 /* Assets.xcassets */, 79 | BBFA87151CE1D7FF00439E68 /* LaunchScreen.storyboard */, 80 | BBFA87181CE1D7FF00439E68 /* Info.plist */, 81 | ); 82 | path = ColorAdapativeStatusBarExample; 83 | sourceTree = ""; 84 | }; 85 | /* End PBXGroup section */ 86 | 87 | /* Begin PBXNativeTarget section */ 88 | BBFA87081CE1D7FF00439E68 /* ColorAdapativeStatusBarExample */ = { 89 | isa = PBXNativeTarget; 90 | buildConfigurationList = BBFA871B1CE1D7FF00439E68 /* Build configuration list for PBXNativeTarget "ColorAdapativeStatusBarExample" */; 91 | buildPhases = ( 92 | BBFA87051CE1D7FF00439E68 /* Sources */, 93 | BBFA87061CE1D7FF00439E68 /* Frameworks */, 94 | BBFA87071CE1D7FF00439E68 /* Resources */, 95 | ); 96 | buildRules = ( 97 | ); 98 | dependencies = ( 99 | ); 100 | name = ColorAdapativeStatusBarExample; 101 | productName = ColorAdapativeStatusBarExample; 102 | productReference = BBFA87091CE1D7FF00439E68 /* ColorAdapativeStatusBarExample.app */; 103 | productType = "com.apple.product-type.application"; 104 | }; 105 | /* End PBXNativeTarget section */ 106 | 107 | /* Begin PBXProject section */ 108 | BBFA87011CE1D7FF00439E68 /* Project object */ = { 109 | isa = PBXProject; 110 | attributes = { 111 | LastSwiftUpdateCheck = 0720; 112 | LastUpgradeCheck = 0720; 113 | ORGANIZATIONNAME = Simon; 114 | TargetAttributes = { 115 | BBFA87081CE1D7FF00439E68 = { 116 | CreatedOnToolsVersion = 7.2.1; 117 | }; 118 | }; 119 | }; 120 | buildConfigurationList = BBFA87041CE1D7FF00439E68 /* Build configuration list for PBXProject "ColorAdapativeStatusBarExample" */; 121 | compatibilityVersion = "Xcode 3.2"; 122 | developmentRegion = English; 123 | hasScannedForEncodings = 0; 124 | knownRegions = ( 125 | en, 126 | Base, 127 | ); 128 | mainGroup = BBFA87001CE1D7FF00439E68; 129 | productRefGroup = BBFA870A1CE1D7FF00439E68 /* Products */; 130 | projectDirPath = ""; 131 | projectRoot = ""; 132 | targets = ( 133 | BBFA87081CE1D7FF00439E68 /* ColorAdapativeStatusBarExample */, 134 | ); 135 | }; 136 | /* End PBXProject section */ 137 | 138 | /* Begin PBXResourcesBuildPhase section */ 139 | BBFA87071CE1D7FF00439E68 /* Resources */ = { 140 | isa = PBXResourcesBuildPhase; 141 | buildActionMask = 2147483647; 142 | files = ( 143 | BBFA87261CE1D81B00439E68 /* Rock.png in Resources */, 144 | BBFA87271CE1D81B00439E68 /* Sky.png in Resources */, 145 | BBFA87231CE1D81B00439E68 /* Flower.png in Resources */, 146 | BBFA87171CE1D7FF00439E68 /* LaunchScreen.storyboard in Resources */, 147 | BBFA87241CE1D81B00439E68 /* Type.png in Resources */, 148 | BBFA87251CE1D81B00439E68 /* Leaf.png in Resources */, 149 | BBFA87141CE1D7FF00439E68 /* Assets.xcassets in Resources */, 150 | BBFA87121CE1D7FF00439E68 /* Main.storyboard in Resources */, 151 | ); 152 | runOnlyForDeploymentPostprocessing = 0; 153 | }; 154 | /* End PBXResourcesBuildPhase section */ 155 | 156 | /* Begin PBXSourcesBuildPhase section */ 157 | BBFA87051CE1D7FF00439E68 /* Sources */ = { 158 | isa = PBXSourcesBuildPhase; 159 | buildActionMask = 2147483647; 160 | files = ( 161 | BB233BE41CE232CD00FABB0F /* README.md in Sources */, 162 | BBFA870F1CE1D7FF00439E68 /* ViewController.swift in Sources */, 163 | BBFA870D1CE1D7FF00439E68 /* AppDelegate.swift in Sources */, 164 | ); 165 | runOnlyForDeploymentPostprocessing = 0; 166 | }; 167 | /* End PBXSourcesBuildPhase section */ 168 | 169 | /* Begin PBXVariantGroup section */ 170 | BBFA87101CE1D7FF00439E68 /* Main.storyboard */ = { 171 | isa = PBXVariantGroup; 172 | children = ( 173 | BBFA87111CE1D7FF00439E68 /* Base */, 174 | ); 175 | name = Main.storyboard; 176 | sourceTree = ""; 177 | }; 178 | BBFA87151CE1D7FF00439E68 /* LaunchScreen.storyboard */ = { 179 | isa = PBXVariantGroup; 180 | children = ( 181 | BBFA87161CE1D7FF00439E68 /* Base */, 182 | ); 183 | name = LaunchScreen.storyboard; 184 | sourceTree = ""; 185 | }; 186 | /* End PBXVariantGroup section */ 187 | 188 | /* Begin XCBuildConfiguration section */ 189 | BBFA87191CE1D7FF00439E68 /* Debug */ = { 190 | isa = XCBuildConfiguration; 191 | buildSettings = { 192 | ALWAYS_SEARCH_USER_PATHS = NO; 193 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 194 | CLANG_CXX_LIBRARY = "libc++"; 195 | CLANG_ENABLE_MODULES = YES; 196 | CLANG_ENABLE_OBJC_ARC = YES; 197 | CLANG_WARN_BOOL_CONVERSION = YES; 198 | CLANG_WARN_CONSTANT_CONVERSION = YES; 199 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 200 | CLANG_WARN_EMPTY_BODY = YES; 201 | CLANG_WARN_ENUM_CONVERSION = YES; 202 | CLANG_WARN_INT_CONVERSION = YES; 203 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 204 | CLANG_WARN_UNREACHABLE_CODE = YES; 205 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 206 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 207 | COPY_PHASE_STRIP = NO; 208 | DEBUG_INFORMATION_FORMAT = dwarf; 209 | ENABLE_STRICT_OBJC_MSGSEND = YES; 210 | ENABLE_TESTABILITY = YES; 211 | GCC_C_LANGUAGE_STANDARD = gnu99; 212 | GCC_DYNAMIC_NO_PIC = NO; 213 | GCC_NO_COMMON_BLOCKS = YES; 214 | GCC_OPTIMIZATION_LEVEL = 0; 215 | GCC_PREPROCESSOR_DEFINITIONS = ( 216 | "DEBUG=1", 217 | "$(inherited)", 218 | ); 219 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 220 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 221 | GCC_WARN_UNDECLARED_SELECTOR = YES; 222 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 223 | GCC_WARN_UNUSED_FUNCTION = YES; 224 | GCC_WARN_UNUSED_VARIABLE = YES; 225 | IPHONEOS_DEPLOYMENT_TARGET = 9.2; 226 | MTL_ENABLE_DEBUG_INFO = YES; 227 | ONLY_ACTIVE_ARCH = YES; 228 | SDKROOT = iphoneos; 229 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 230 | TARGETED_DEVICE_FAMILY = "1,2"; 231 | }; 232 | name = Debug; 233 | }; 234 | BBFA871A1CE1D7FF00439E68 /* Release */ = { 235 | isa = XCBuildConfiguration; 236 | buildSettings = { 237 | ALWAYS_SEARCH_USER_PATHS = NO; 238 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 239 | CLANG_CXX_LIBRARY = "libc++"; 240 | CLANG_ENABLE_MODULES = YES; 241 | CLANG_ENABLE_OBJC_ARC = YES; 242 | CLANG_WARN_BOOL_CONVERSION = YES; 243 | CLANG_WARN_CONSTANT_CONVERSION = YES; 244 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 245 | CLANG_WARN_EMPTY_BODY = YES; 246 | CLANG_WARN_ENUM_CONVERSION = YES; 247 | CLANG_WARN_INT_CONVERSION = YES; 248 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 249 | CLANG_WARN_UNREACHABLE_CODE = YES; 250 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 251 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 252 | COPY_PHASE_STRIP = NO; 253 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 254 | ENABLE_NS_ASSERTIONS = NO; 255 | ENABLE_STRICT_OBJC_MSGSEND = YES; 256 | GCC_C_LANGUAGE_STANDARD = gnu99; 257 | GCC_NO_COMMON_BLOCKS = YES; 258 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 259 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 260 | GCC_WARN_UNDECLARED_SELECTOR = YES; 261 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 262 | GCC_WARN_UNUSED_FUNCTION = YES; 263 | GCC_WARN_UNUSED_VARIABLE = YES; 264 | IPHONEOS_DEPLOYMENT_TARGET = 9.2; 265 | MTL_ENABLE_DEBUG_INFO = NO; 266 | SDKROOT = iphoneos; 267 | TARGETED_DEVICE_FAMILY = "1,2"; 268 | VALIDATE_PRODUCT = YES; 269 | }; 270 | name = Release; 271 | }; 272 | BBFA871C1CE1D7FF00439E68 /* Debug */ = { 273 | isa = XCBuildConfiguration; 274 | buildSettings = { 275 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 276 | INFOPLIST_FILE = ColorAdapativeStatusBarExample/Info.plist; 277 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 278 | PRODUCT_BUNDLE_IDENTIFIER = None.ColorAdapativeStatusBarExample; 279 | PRODUCT_NAME = "$(TARGET_NAME)"; 280 | }; 281 | name = Debug; 282 | }; 283 | BBFA871D1CE1D7FF00439E68 /* Release */ = { 284 | isa = XCBuildConfiguration; 285 | buildSettings = { 286 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 287 | INFOPLIST_FILE = ColorAdapativeStatusBarExample/Info.plist; 288 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 289 | PRODUCT_BUNDLE_IDENTIFIER = None.ColorAdapativeStatusBarExample; 290 | PRODUCT_NAME = "$(TARGET_NAME)"; 291 | }; 292 | name = Release; 293 | }; 294 | /* End XCBuildConfiguration section */ 295 | 296 | /* Begin XCConfigurationList section */ 297 | BBFA87041CE1D7FF00439E68 /* Build configuration list for PBXProject "ColorAdapativeStatusBarExample" */ = { 298 | isa = XCConfigurationList; 299 | buildConfigurations = ( 300 | BBFA87191CE1D7FF00439E68 /* Debug */, 301 | BBFA871A1CE1D7FF00439E68 /* Release */, 302 | ); 303 | defaultConfigurationIsVisible = 0; 304 | defaultConfigurationName = Release; 305 | }; 306 | BBFA871B1CE1D7FF00439E68 /* Build configuration list for PBXNativeTarget "ColorAdapativeStatusBarExample" */ = { 307 | isa = XCConfigurationList; 308 | buildConfigurations = ( 309 | BBFA871C1CE1D7FF00439E68 /* Debug */, 310 | BBFA871D1CE1D7FF00439E68 /* Release */, 311 | ); 312 | defaultConfigurationIsVisible = 0; 313 | defaultConfigurationName = Release; 314 | }; 315 | /* End XCConfigurationList section */ 316 | }; 317 | rootObject = BBFA87011CE1D7FF00439E68 /* Project object */; 318 | } 319 | -------------------------------------------------------------------------------- /ColorAdapativeStatusBarExample.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /ColorAdapativeStatusBarExample.xcodeproj/xcuserdata/simontseng.xcuserdatad/xcschemes/ColorAdapativeStatusBarExample.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 39 | 40 | 41 | 42 | 43 | 44 | 54 | 56 | 62 | 63 | 64 | 65 | 66 | 67 | 73 | 75 | 81 | 82 | 83 | 84 | 86 | 87 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /ColorAdapativeStatusBarExample.xcodeproj/xcuserdata/simontseng.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | ColorAdapativeStatusBarExample.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | BBFA87081CE1D7FF00439E68 16 | 17 | primary 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /ColorAdapativeStatusBarExample/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // ColorAdapativeStatusBarExample 4 | // 5 | // Created by Simon on 2016/5/10. 6 | // Copyright © 2016年 Simon. 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: [NSObject: AnyObject]?) -> 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 | -------------------------------------------------------------------------------- /ColorAdapativeStatusBarExample/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 | "info" : { 65 | "version" : 1, 66 | "author" : "xcode" 67 | } 68 | } -------------------------------------------------------------------------------- /ColorAdapativeStatusBarExample/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 | -------------------------------------------------------------------------------- /ColorAdapativeStatusBarExample/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 | -------------------------------------------------------------------------------- /ColorAdapativeStatusBarExample/Flower.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Simon-Tseng/ColorAdapativeStatusBarExample/55ebd5f1bee944bc60818e14b4941813f54d78d6/ColorAdapativeStatusBarExample/Flower.png -------------------------------------------------------------------------------- /ColorAdapativeStatusBarExample/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 | 39 | UISupportedInterfaceOrientations~ipad 40 | 41 | UIInterfaceOrientationPortrait 42 | UIInterfaceOrientationPortraitUpsideDown 43 | UIInterfaceOrientationLandscapeLeft 44 | UIInterfaceOrientationLandscapeRight 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /ColorAdapativeStatusBarExample/Leaf.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Simon-Tseng/ColorAdapativeStatusBarExample/55ebd5f1bee944bc60818e14b4941813f54d78d6/ColorAdapativeStatusBarExample/Leaf.png -------------------------------------------------------------------------------- /ColorAdapativeStatusBarExample/Rock.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Simon-Tseng/ColorAdapativeStatusBarExample/55ebd5f1bee944bc60818e14b4941813f54d78d6/ColorAdapativeStatusBarExample/Rock.png -------------------------------------------------------------------------------- /ColorAdapativeStatusBarExample/Sky.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Simon-Tseng/ColorAdapativeStatusBarExample/55ebd5f1bee944bc60818e14b4941813f54d78d6/ColorAdapativeStatusBarExample/Sky.png -------------------------------------------------------------------------------- /ColorAdapativeStatusBarExample/Type.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Simon-Tseng/ColorAdapativeStatusBarExample/55ebd5f1bee944bc60818e14b4941813f54d78d6/ColorAdapativeStatusBarExample/Type.png -------------------------------------------------------------------------------- /ColorAdapativeStatusBarExample/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // ColorAdapativeStatusBarExample 4 | // 5 | // Created by Simon on 2016/4/18. 6 | // Copyright © 2016年 Simon. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | struct K { 12 | static let bannerImageHeight: CGFloat = 200.0 13 | static let bannerBackgroundHeight: CGFloat = 40.0 14 | } 15 | 16 | class ViewController: UIViewController, UIScrollViewDelegate { 17 | 18 | // 顯示Banner區塊的ScrollView 19 | var mainScrollView: UIScrollView! 20 | 21 | // 當成StatusBar背景色的ScrollView 22 | var statusBarScrollView: UIScrollView! 23 | 24 | 25 | // Banner背景色 26 | let bannerBGColorAry: [UIColor] = [ 27 | UIColor(hex: 0xFF60AF), 28 | UIColor(hex: 0xFFD306), 29 | UIColor(hex: 0x73BF00), 30 | UIColor(hex: 0x0080FF), 31 | UIColor(hex: 0xEA7500) 32 | ] 33 | 34 | // Banner圖片 35 | let bannerImageAry: [UIImage] = [ 36 | UIImage(named: "Flower")!, 37 | UIImage(named: "Type")!, 38 | UIImage(named: "Leaf")!, 39 | UIImage(named: "Sky")!, 40 | UIImage(named: "Rock")!] 41 | 42 | 43 | override func viewDidLoad() { 44 | super.viewDidLoad() 45 | 46 | let screenWidth: CGFloat = UIScreen.mainScreen().bounds.size.width 47 | let bannerHeight: CGFloat = K.bannerImageHeight + K.bannerBackgroundHeight 48 | 49 | // 設定Banner區塊的ScrollView 50 | self.mainScrollView = UIScrollView() 51 | self.mainScrollView.frame = UIScreen.mainScreen().bounds 52 | self.mainScrollView.delegate = self 53 | self.mainScrollView.contentSize = CGSizeMake(screenWidth, bannerHeight * CGFloat(bannerBGColorAry.count)) 54 | self.view.addSubview(self.mainScrollView) 55 | 56 | // 將Banner區塊加到ScrollView 57 | for (index, bgColor) in self.bannerBGColorAry.enumerate() { 58 | // 載入Banner的背景色 59 | let yPos = CGFloat(index) * bannerHeight 60 | let banner = UIView(frame: CGRectMake(0, yPos, screenWidth, bannerHeight)) 61 | banner.backgroundColor = bgColor 62 | 63 | // 載入Banner的照片 64 | let bannerImage: UIImageView = UIImageView(frame: CGRectMake(0, 0, screenWidth, K.bannerImageHeight)) 65 | bannerImage.image = self.bannerImageAry[index] 66 | bannerImage.contentMode = UIViewContentMode.ScaleAspectFill 67 | bannerImage.clipsToBounds = true 68 | banner.addSubview(bannerImage) 69 | 70 | self.mainScrollView.addSubview(banner) 71 | } 72 | 73 | 74 | // 設定StatusBar背景色的ScrollView 75 | self.statusBarScrollView = UIScrollView() 76 | self.statusBarScrollView.userInteractionEnabled = false 77 | self.statusBarScrollView.showsHorizontalScrollIndicator = false 78 | self.statusBarScrollView.showsVerticalScrollIndicator = false 79 | let statusBarHeight = UIApplication.sharedApplication().statusBarFrame.size.height 80 | self.statusBarScrollView.frame = CGRectMake(0, 0, screenWidth, statusBarHeight) 81 | self.statusBarScrollView.contentSize = self.mainScrollView.contentSize 82 | self.view.addSubview(self.statusBarScrollView) 83 | 84 | // 只載入Banner的背景色 85 | for (index, bgColor) in self.bannerBGColorAry.enumerate() { 86 | let yPos = CGFloat(index) * bannerHeight 87 | let banner = UIView(frame: CGRectMake(0, yPos, screenWidth, bannerHeight)) 88 | banner.backgroundColor = bgColor 89 | 90 | self.statusBarScrollView.addSubview(banner) 91 | } 92 | 93 | 94 | } 95 | 96 | 97 | func scrollViewDidScroll(scrollView: UIScrollView) 98 | { 99 | // 讓statusBarScrollView跟著mainScrollView連動,就可以讓StatusBar的底色跟著改變。 100 | self.statusBarScrollView.contentOffset = self.mainScrollView.contentOffset 101 | } 102 | 103 | 104 | override func didReceiveMemoryWarning() { 105 | super.didReceiveMemoryWarning() 106 | // Dispose of any resources that can be recreated. 107 | } 108 | 109 | 110 | } 111 | 112 | 113 | extension UIColor { 114 | 115 | convenience init(hex: Int) { 116 | let components = ( 117 | R: CGFloat((hex >> 16) & 0xff) / 255, 118 | G: CGFloat((hex >> 08) & 0xff) / 255, 119 | B: CGFloat((hex >> 00) & 0xff) / 255 120 | ) 121 | 122 | self.init(red: components.R, green: components.G, blue: components.B, alpha: 1) 123 | } 124 | 125 | } 126 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ColorAdapativeStatusBarExample 2 | 3 | 這是一個讓statusBar的底色跟著內容滑動變化的實作範例,詳細說明請參考: 4 | 5 | [https://medium.com/@Simon_Tseng/test-b1d3a2e811fc#.2ilrfu31r](https://medium.com/@Simon_Tseng/test-b1d3a2e811fc#.2ilrfu31r) 6 | 7 | 點選下面圖片可以看到完成的效果: 8 | 9 | [![IMAGE ALT TEXT](http://img.youtube.com/vi/VUbdVrzokxk/0.jpg)](http://www.youtube.com/watch?v=VUbdVrzokxk "讓statusBar的底色跟著內容滑動變化") 10 | --------------------------------------------------------------------------------