├── DemoApp.xcodeproj ├── project.pbxproj └── project.xcworkspace │ └── contents.xcworkspacedata ├── DemoApp ├── AppDelegate.h ├── AppDelegate.m ├── Default-568h@2x.png ├── Default.png ├── Default@2x.png ├── DemoApp-Info.plist ├── DemoApp-Prefix.pch ├── Screenshot │ └── screenshot1.png ├── ViewController.h ├── ViewController.m ├── en.lproj │ ├── InfoPlist.strings │ └── MainStoryboard.storyboard └── main.m ├── LICENSE ├── NJKWebViewProgress.podspec ├── NJKWebViewProgress ├── NJKWebViewProgress.h ├── NJKWebViewProgress.m ├── NJKWebViewProgressView.h └── NJKWebViewProgressView.m └── README.md /DemoApp.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 260C2937183704EE0099D1B6 /* NJKWebViewProgressView.m in Sources */ = {isa = PBXBuildFile; fileRef = 260C2936183704EE0099D1B6 /* NJKWebViewProgressView.m */; }; 11 | 2677297317245E5C00D4E159 /* NJKWebViewProgress.m in Sources */ = {isa = PBXBuildFile; fileRef = 2677297217245E5C00D4E159 /* NJKWebViewProgress.m */; }; 12 | 2677297817245E7900D4E159 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 2677297517245E7900D4E159 /* AppDelegate.m */; }; 13 | 2677297917245E7900D4E159 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 2677297717245E7900D4E159 /* ViewController.m */; }; 14 | 2677297E17245E8E00D4E159 /* Default-568h@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 2677297A17245E8E00D4E159 /* Default-568h@2x.png */; }; 15 | 2677297F17245E8E00D4E159 /* Default.png in Resources */ = {isa = PBXBuildFile; fileRef = 2677297B17245E8E00D4E159 /* Default.png */; }; 16 | 2677298017245E8E00D4E159 /* Default@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 2677297C17245E8E00D4E159 /* Default@2x.png */; }; 17 | 2677298117245E8E00D4E159 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 2677297D17245E8E00D4E159 /* main.m */; }; 18 | 2677298A17245EB000D4E159 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 2677298617245EB000D4E159 /* InfoPlist.strings */; }; 19 | 2677298B17245EB000D4E159 /* MainStoryboard.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 2677298817245EB000D4E159 /* MainStoryboard.storyboard */; }; 20 | 26E5744A172235B500203262 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 26E57449172235B500203262 /* UIKit.framework */; }; 21 | 26E5744C172235B500203262 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 26E5744B172235B500203262 /* Foundation.framework */; }; 22 | 26E5744E172235B500203262 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 26E5744D172235B500203262 /* CoreGraphics.framework */; }; 23 | /* End PBXBuildFile section */ 24 | 25 | /* Begin PBXFileReference section */ 26 | 260C2935183704EE0099D1B6 /* NJKWebViewProgressView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = NJKWebViewProgressView.h; path = NJKWebViewProgress/NJKWebViewProgressView.h; sourceTree = SOURCE_ROOT; }; 27 | 260C2936183704EE0099D1B6 /* NJKWebViewProgressView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = NJKWebViewProgressView.m; path = NJKWebViewProgress/NJKWebViewProgressView.m; sourceTree = SOURCE_ROOT; }; 28 | 2677297117245E5C00D4E159 /* NJKWebViewProgress.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = NJKWebViewProgress.h; path = NJKWebViewProgress/NJKWebViewProgress.h; sourceTree = SOURCE_ROOT; }; 29 | 2677297217245E5C00D4E159 /* NJKWebViewProgress.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = NJKWebViewProgress.m; path = NJKWebViewProgress/NJKWebViewProgress.m; sourceTree = SOURCE_ROOT; }; 30 | 2677297417245E7900D4E159 /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AppDelegate.h; path = DemoApp/AppDelegate.h; sourceTree = SOURCE_ROOT; }; 31 | 2677297517245E7900D4E159 /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = AppDelegate.m; path = DemoApp/AppDelegate.m; sourceTree = SOURCE_ROOT; }; 32 | 2677297617245E7900D4E159 /* ViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ViewController.h; path = DemoApp/ViewController.h; sourceTree = SOURCE_ROOT; }; 33 | 2677297717245E7900D4E159 /* ViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = ViewController.m; path = DemoApp/ViewController.m; sourceTree = SOURCE_ROOT; }; 34 | 2677297A17245E8E00D4E159 /* Default-568h@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Default-568h@2x.png"; path = "DemoApp/Default-568h@2x.png"; sourceTree = SOURCE_ROOT; }; 35 | 2677297B17245E8E00D4E159 /* Default.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = Default.png; path = DemoApp/Default.png; sourceTree = SOURCE_ROOT; }; 36 | 2677297C17245E8E00D4E159 /* Default@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Default@2x.png"; path = "DemoApp/Default@2x.png"; sourceTree = SOURCE_ROOT; }; 37 | 2677297D17245E8E00D4E159 /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = main.m; path = DemoApp/main.m; sourceTree = SOURCE_ROOT; }; 38 | 2677298217245E9800D4E159 /* DemoApp-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = "DemoApp-Info.plist"; path = "DemoApp/DemoApp-Info.plist"; sourceTree = SOURCE_ROOT; }; 39 | 2677298417245EA000D4E159 /* DemoApp-Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "DemoApp-Prefix.pch"; path = "DemoApp/DemoApp-Prefix.pch"; sourceTree = SOURCE_ROOT; }; 40 | 2677298717245EB000D4E159 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = InfoPlist.strings; sourceTree = ""; }; 41 | 2677298917245EB000D4E159 /* en */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = en; path = MainStoryboard.storyboard; sourceTree = ""; }; 42 | 26E57446172235B500203262 /* DemoApp.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = DemoApp.app; sourceTree = BUILT_PRODUCTS_DIR; }; 43 | 26E57449172235B500203262 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; 44 | 26E5744B172235B500203262 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; 45 | 26E5744D172235B500203262 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; 46 | /* End PBXFileReference section */ 47 | 48 | /* Begin PBXFrameworksBuildPhase section */ 49 | 26E57443172235B500203262 /* Frameworks */ = { 50 | isa = PBXFrameworksBuildPhase; 51 | buildActionMask = 2147483647; 52 | files = ( 53 | 26E5744A172235B500203262 /* UIKit.framework in Frameworks */, 54 | 26E5744C172235B500203262 /* Foundation.framework in Frameworks */, 55 | 26E5744E172235B500203262 /* CoreGraphics.framework in Frameworks */, 56 | ); 57 | runOnlyForDeploymentPostprocessing = 0; 58 | }; 59 | /* End PBXFrameworksBuildPhase section */ 60 | 61 | /* Begin PBXGroup section */ 62 | 260C2938183713360099D1B6 /* NJKWebViewProgress */ = { 63 | isa = PBXGroup; 64 | children = ( 65 | 2677297117245E5C00D4E159 /* NJKWebViewProgress.h */, 66 | 2677297217245E5C00D4E159 /* NJKWebViewProgress.m */, 67 | 260C2935183704EE0099D1B6 /* NJKWebViewProgressView.h */, 68 | 260C2936183704EE0099D1B6 /* NJKWebViewProgressView.m */, 69 | ); 70 | name = NJKWebViewProgress; 71 | sourceTree = ""; 72 | }; 73 | 2677298517245EB000D4E159 /* en.lproj */ = { 74 | isa = PBXGroup; 75 | children = ( 76 | 2677298617245EB000D4E159 /* InfoPlist.strings */, 77 | 2677298817245EB000D4E159 /* MainStoryboard.storyboard */, 78 | ); 79 | name = en.lproj; 80 | path = DemoApp/en.lproj; 81 | sourceTree = SOURCE_ROOT; 82 | }; 83 | 26E5743D172235B500203262 = { 84 | isa = PBXGroup; 85 | children = ( 86 | 26E5744F172235B500203262 /* DemoApp */, 87 | 26E57448172235B500203262 /* Frameworks */, 88 | 26E57447172235B500203262 /* Products */, 89 | ); 90 | sourceTree = ""; 91 | }; 92 | 26E57447172235B500203262 /* Products */ = { 93 | isa = PBXGroup; 94 | children = ( 95 | 26E57446172235B500203262 /* DemoApp.app */, 96 | ); 97 | name = Products; 98 | sourceTree = ""; 99 | }; 100 | 26E57448172235B500203262 /* Frameworks */ = { 101 | isa = PBXGroup; 102 | children = ( 103 | 26E57449172235B500203262 /* UIKit.framework */, 104 | 26E5744B172235B500203262 /* Foundation.framework */, 105 | 26E5744D172235B500203262 /* CoreGraphics.framework */, 106 | ); 107 | name = Frameworks; 108 | sourceTree = ""; 109 | }; 110 | 26E5744F172235B500203262 /* DemoApp */ = { 111 | isa = PBXGroup; 112 | children = ( 113 | 260C2938183713360099D1B6 /* NJKWebViewProgress */, 114 | 2677297417245E7900D4E159 /* AppDelegate.h */, 115 | 2677297517245E7900D4E159 /* AppDelegate.m */, 116 | 2677297617245E7900D4E159 /* ViewController.h */, 117 | 2677297717245E7900D4E159 /* ViewController.m */, 118 | 26E57450172235B500203262 /* Supporting Files */, 119 | ); 120 | name = DemoApp; 121 | path = WebViewSample; 122 | sourceTree = ""; 123 | }; 124 | 26E57450172235B500203262 /* Supporting Files */ = { 125 | isa = PBXGroup; 126 | children = ( 127 | 2677298517245EB000D4E159 /* en.lproj */, 128 | 2677298417245EA000D4E159 /* DemoApp-Prefix.pch */, 129 | 2677297A17245E8E00D4E159 /* Default-568h@2x.png */, 130 | 2677297B17245E8E00D4E159 /* Default.png */, 131 | 2677297C17245E8E00D4E159 /* Default@2x.png */, 132 | 2677297D17245E8E00D4E159 /* main.m */, 133 | 2677298217245E9800D4E159 /* DemoApp-Info.plist */, 134 | ); 135 | name = "Supporting Files"; 136 | sourceTree = ""; 137 | }; 138 | /* End PBXGroup section */ 139 | 140 | /* Begin PBXNativeTarget section */ 141 | 26E57445172235B500203262 /* DemoApp */ = { 142 | isa = PBXNativeTarget; 143 | buildConfigurationList = 26E57469172235B500203262 /* Build configuration list for PBXNativeTarget "DemoApp" */; 144 | buildPhases = ( 145 | 26E57442172235B500203262 /* Sources */, 146 | 26E57443172235B500203262 /* Frameworks */, 147 | 26E57444172235B500203262 /* Resources */, 148 | ); 149 | buildRules = ( 150 | ); 151 | dependencies = ( 152 | ); 153 | name = DemoApp; 154 | productName = WebViewSample; 155 | productReference = 26E57446172235B500203262 /* DemoApp.app */; 156 | productType = "com.apple.product-type.application"; 157 | }; 158 | /* End PBXNativeTarget section */ 159 | 160 | /* Begin PBXProject section */ 161 | 26E5743E172235B500203262 /* Project object */ = { 162 | isa = PBXProject; 163 | attributes = { 164 | LastUpgradeCheck = 0460; 165 | ORGANIZATIONNAME = "Satoshi Asano"; 166 | }; 167 | buildConfigurationList = 26E57441172235B500203262 /* Build configuration list for PBXProject "DemoApp" */; 168 | compatibilityVersion = "Xcode 3.2"; 169 | developmentRegion = English; 170 | hasScannedForEncodings = 0; 171 | knownRegions = ( 172 | en, 173 | ); 174 | mainGroup = 26E5743D172235B500203262; 175 | productRefGroup = 26E57447172235B500203262 /* Products */; 176 | projectDirPath = ""; 177 | projectRoot = ""; 178 | targets = ( 179 | 26E57445172235B500203262 /* DemoApp */, 180 | ); 181 | }; 182 | /* End PBXProject section */ 183 | 184 | /* Begin PBXResourcesBuildPhase section */ 185 | 26E57444172235B500203262 /* Resources */ = { 186 | isa = PBXResourcesBuildPhase; 187 | buildActionMask = 2147483647; 188 | files = ( 189 | 2677297E17245E8E00D4E159 /* Default-568h@2x.png in Resources */, 190 | 2677297F17245E8E00D4E159 /* Default.png in Resources */, 191 | 2677298017245E8E00D4E159 /* Default@2x.png in Resources */, 192 | 2677298A17245EB000D4E159 /* InfoPlist.strings in Resources */, 193 | 2677298B17245EB000D4E159 /* MainStoryboard.storyboard in Resources */, 194 | ); 195 | runOnlyForDeploymentPostprocessing = 0; 196 | }; 197 | /* End PBXResourcesBuildPhase section */ 198 | 199 | /* Begin PBXSourcesBuildPhase section */ 200 | 26E57442172235B500203262 /* Sources */ = { 201 | isa = PBXSourcesBuildPhase; 202 | buildActionMask = 2147483647; 203 | files = ( 204 | 2677297317245E5C00D4E159 /* NJKWebViewProgress.m in Sources */, 205 | 260C2937183704EE0099D1B6 /* NJKWebViewProgressView.m in Sources */, 206 | 2677297817245E7900D4E159 /* AppDelegate.m in Sources */, 207 | 2677297917245E7900D4E159 /* ViewController.m in Sources */, 208 | 2677298117245E8E00D4E159 /* main.m in Sources */, 209 | ); 210 | runOnlyForDeploymentPostprocessing = 0; 211 | }; 212 | /* End PBXSourcesBuildPhase section */ 213 | 214 | /* Begin PBXVariantGroup section */ 215 | 2677298617245EB000D4E159 /* InfoPlist.strings */ = { 216 | isa = PBXVariantGroup; 217 | children = ( 218 | 2677298717245EB000D4E159 /* en */, 219 | ); 220 | name = InfoPlist.strings; 221 | sourceTree = ""; 222 | }; 223 | 2677298817245EB000D4E159 /* MainStoryboard.storyboard */ = { 224 | isa = PBXVariantGroup; 225 | children = ( 226 | 2677298917245EB000D4E159 /* en */, 227 | ); 228 | name = MainStoryboard.storyboard; 229 | sourceTree = ""; 230 | }; 231 | /* End PBXVariantGroup section */ 232 | 233 | /* Begin XCBuildConfiguration section */ 234 | 26E57467172235B500203262 /* Debug */ = { 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_OBJC_ARC = YES; 241 | CLANG_WARN_CONSTANT_CONVERSION = YES; 242 | CLANG_WARN_EMPTY_BODY = YES; 243 | CLANG_WARN_ENUM_CONVERSION = YES; 244 | CLANG_WARN_INT_CONVERSION = YES; 245 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 246 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 247 | COPY_PHASE_STRIP = NO; 248 | GCC_C_LANGUAGE_STANDARD = gnu99; 249 | GCC_DYNAMIC_NO_PIC = NO; 250 | GCC_OPTIMIZATION_LEVEL = 0; 251 | GCC_PREPROCESSOR_DEFINITIONS = ( 252 | "DEBUG=1", 253 | "$(inherited)", 254 | ); 255 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 256 | GCC_WARN_ABOUT_RETURN_TYPE = YES; 257 | GCC_WARN_UNINITIALIZED_AUTOS = YES; 258 | GCC_WARN_UNUSED_VARIABLE = YES; 259 | IPHONEOS_DEPLOYMENT_TARGET = 6.1; 260 | ONLY_ACTIVE_ARCH = YES; 261 | SDKROOT = iphoneos; 262 | }; 263 | name = Debug; 264 | }; 265 | 26E57468172235B500203262 /* Release */ = { 266 | isa = XCBuildConfiguration; 267 | buildSettings = { 268 | ALWAYS_SEARCH_USER_PATHS = NO; 269 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 270 | CLANG_CXX_LIBRARY = "libc++"; 271 | CLANG_ENABLE_OBJC_ARC = YES; 272 | CLANG_WARN_CONSTANT_CONVERSION = YES; 273 | CLANG_WARN_EMPTY_BODY = YES; 274 | CLANG_WARN_ENUM_CONVERSION = YES; 275 | CLANG_WARN_INT_CONVERSION = YES; 276 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 277 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 278 | COPY_PHASE_STRIP = YES; 279 | GCC_C_LANGUAGE_STANDARD = gnu99; 280 | GCC_WARN_ABOUT_RETURN_TYPE = YES; 281 | GCC_WARN_UNINITIALIZED_AUTOS = YES; 282 | GCC_WARN_UNUSED_VARIABLE = YES; 283 | IPHONEOS_DEPLOYMENT_TARGET = 6.1; 284 | OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1"; 285 | SDKROOT = iphoneos; 286 | VALIDATE_PRODUCT = YES; 287 | }; 288 | name = Release; 289 | }; 290 | 26E5746A172235B500203262 /* Debug */ = { 291 | isa = XCBuildConfiguration; 292 | buildSettings = { 293 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 294 | GCC_PREFIX_HEADER = "DemoApp/DemoApp-Prefix.pch"; 295 | INFOPLIST_FILE = "DemoApp/DemoApp-Info.plist"; 296 | IPHONEOS_DEPLOYMENT_TARGET = 7.0; 297 | PRODUCT_NAME = "$(TARGET_NAME)"; 298 | TARGETED_DEVICE_FAMILY = "1,2"; 299 | WRAPPER_EXTENSION = app; 300 | }; 301 | name = Debug; 302 | }; 303 | 26E5746B172235B500203262 /* Release */ = { 304 | isa = XCBuildConfiguration; 305 | buildSettings = { 306 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 307 | GCC_PREFIX_HEADER = "DemoApp/DemoApp-Prefix.pch"; 308 | INFOPLIST_FILE = "DemoApp/DemoApp-Info.plist"; 309 | IPHONEOS_DEPLOYMENT_TARGET = 7.0; 310 | PRODUCT_NAME = "$(TARGET_NAME)"; 311 | TARGETED_DEVICE_FAMILY = "1,2"; 312 | WRAPPER_EXTENSION = app; 313 | }; 314 | name = Release; 315 | }; 316 | /* End XCBuildConfiguration section */ 317 | 318 | /* Begin XCConfigurationList section */ 319 | 26E57441172235B500203262 /* Build configuration list for PBXProject "DemoApp" */ = { 320 | isa = XCConfigurationList; 321 | buildConfigurations = ( 322 | 26E57467172235B500203262 /* Debug */, 323 | 26E57468172235B500203262 /* Release */, 324 | ); 325 | defaultConfigurationIsVisible = 0; 326 | defaultConfigurationName = Release; 327 | }; 328 | 26E57469172235B500203262 /* Build configuration list for PBXNativeTarget "DemoApp" */ = { 329 | isa = XCConfigurationList; 330 | buildConfigurations = ( 331 | 26E5746A172235B500203262 /* Debug */, 332 | 26E5746B172235B500203262 /* Release */, 333 | ); 334 | defaultConfigurationIsVisible = 0; 335 | defaultConfigurationName = Release; 336 | }; 337 | /* End XCConfigurationList section */ 338 | }; 339 | rootObject = 26E5743E172235B500203262 /* Project object */; 340 | } 341 | -------------------------------------------------------------------------------- /DemoApp.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /DemoApp/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // WebViewSample 4 | // 5 | // Created by 浅野 慧 on 4/20/13. 6 | // Copyright (c) 2013 Satoshi Asano. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /DemoApp/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // WebViewSample 4 | // 5 | // Created by 浅野 慧 on 4/20/13. 6 | // Copyright (c) 2013 Satoshi Asano. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | 11 | @implementation AppDelegate 12 | 13 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 14 | { 15 | // Override point for customization after application launch. 16 | return YES; 17 | } 18 | 19 | - (void)applicationWillResignActive:(UIApplication *)application 20 | { 21 | // 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. 22 | // 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. 23 | } 24 | 25 | - (void)applicationDidEnterBackground:(UIApplication *)application 26 | { 27 | // 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. 28 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 29 | } 30 | 31 | - (void)applicationWillEnterForeground:(UIApplication *)application 32 | { 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 | - (void)applicationDidBecomeActive:(UIApplication *)application 37 | { 38 | // 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. 39 | } 40 | 41 | - (void)applicationWillTerminate:(UIApplication *)application 42 | { 43 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 44 | } 45 | 46 | @end 47 | -------------------------------------------------------------------------------- /DemoApp/Default-568h@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ninjinkun/NJKWebViewProgress/377b7e1dc58d389369cf9d27dac0cd95ebdbdd04/DemoApp/Default-568h@2x.png -------------------------------------------------------------------------------- /DemoApp/Default.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ninjinkun/NJKWebViewProgress/377b7e1dc58d389369cf9d27dac0cd95ebdbdd04/DemoApp/Default.png -------------------------------------------------------------------------------- /DemoApp/Default@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ninjinkun/NJKWebViewProgress/377b7e1dc58d389369cf9d27dac0cd95ebdbdd04/DemoApp/Default@2x.png -------------------------------------------------------------------------------- /DemoApp/DemoApp-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleDisplayName 8 | ${PRODUCT_NAME} 9 | CFBundleExecutable 10 | ${EXECUTABLE_NAME} 11 | CFBundleIdentifier 12 | com.ninjinkun.webviewprogress.${PRODUCT_NAME:rfc1034identifier} 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | ${PRODUCT_NAME} 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 1.0 25 | LSRequiresIPhoneOS 26 | 27 | UIMainStoryboardFile 28 | MainStoryboard 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | UIInterfaceOrientationLandscapeLeft 37 | UIInterfaceOrientationLandscapeRight 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /DemoApp/DemoApp-Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header for all source files of the 'WebViewSample' target in the 'WebViewSample' project 3 | // 4 | 5 | #import 6 | 7 | #ifndef __IPHONE_5_0 8 | #warning "This project uses features only available in iOS SDK 5.0 and later." 9 | #endif 10 | 11 | #ifdef __OBJC__ 12 | #import 13 | #import 14 | #endif 15 | -------------------------------------------------------------------------------- /DemoApp/Screenshot/screenshot1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ninjinkun/NJKWebViewProgress/377b7e1dc58d389369cf9d27dac0cd95ebdbdd04/DemoApp/Screenshot/screenshot1.png -------------------------------------------------------------------------------- /DemoApp/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // WebViewDemo 4 | // 5 | // Created by Satoshi Asano on 4/20/13. 6 | // Copyright (c) 2013 Satoshi Asano. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "NJKWebViewProgress.h" 11 | @interface ViewController : UIViewController 12 | @end 13 | -------------------------------------------------------------------------------- /DemoApp/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // WebViewDemo 4 | // 5 | // Created by Satoshi Asano on 4/20/13. 6 | // Copyright (c) 2013 Satoshi Asano. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | #import "NJKWebViewProgressView.h" 11 | @implementation ViewController 12 | { 13 | IBOutlet __weak UIWebView *_webView; 14 | NJKWebViewProgressView *_progressView; 15 | NJKWebViewProgress *_progressProxy; 16 | } 17 | 18 | - (void)viewDidLoad 19 | { 20 | [super viewDidLoad]; 21 | 22 | _progressProxy = [[NJKWebViewProgress alloc] init]; 23 | _webView.delegate = _progressProxy; 24 | _progressProxy.webViewProxyDelegate = self; 25 | _progressProxy.progressDelegate = self; 26 | 27 | CGFloat progressBarHeight = 2.f; 28 | CGRect navigationBarBounds = self.navigationController.navigationBar.bounds; 29 | CGRect barFrame = CGRectMake(0, navigationBarBounds.size.height - progressBarHeight, navigationBarBounds.size.width, progressBarHeight); 30 | _progressView = [[NJKWebViewProgressView alloc] initWithFrame:barFrame]; 31 | _progressView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleTopMargin; 32 | 33 | [self loadGoogle]; 34 | } 35 | 36 | - (void)viewWillAppear:(BOOL)animated 37 | { 38 | [super viewWillAppear:animated]; 39 | [self.navigationController.navigationBar addSubview:_progressView]; 40 | } 41 | 42 | -(void)viewWillDisappear:(BOOL)animated 43 | { 44 | [super viewWillDisappear:animated]; 45 | 46 | // Remove progress view 47 | // because UINavigationBar is shared with other ViewControllers 48 | [_progressView removeFromSuperview]; 49 | } 50 | 51 | - (IBAction)searchButtonPushed:(id)sender 52 | { 53 | [self loadGoogle]; 54 | } 55 | 56 | - (IBAction)reloadButtonPushed:(id)sender 57 | { 58 | [_webView reload]; 59 | } 60 | 61 | -(void)loadGoogle 62 | { 63 | NSURLRequest *req = [[NSURLRequest alloc] initWithURL:[NSURL URLWithString:@"https://google.com/"]]; 64 | [_webView loadRequest:req]; 65 | } 66 | 67 | #pragma mark - NJKWebViewProgressDelegate 68 | -(void)webViewProgress:(NJKWebViewProgress *)webViewProgress updateProgress:(float)progress 69 | { 70 | [_progressView setProgress:progress animated:YES]; 71 | self.title = [_webView stringByEvaluatingJavaScriptFromString:@"document.title"]; 72 | } 73 | 74 | @end 75 | -------------------------------------------------------------------------------- /DemoApp/en.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* Localized versions of Info.plist keys */ 2 | 3 | -------------------------------------------------------------------------------- /DemoApp/en.lproj/MainStoryboard.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 | -------------------------------------------------------------------------------- /DemoApp/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // WebViewSample 4 | // 5 | // Created by 浅野 慧 on 4/20/13. 6 | // Copyright (c) 2013 Satoshi Asano. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | #import "AppDelegate.h" 12 | 13 | int main(int argc, char *argv[]) 14 | { 15 | @autoreleasepool { 16 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2013 Satoshi Asano 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 13 | all 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 21 | THE SOFTWARE. -------------------------------------------------------------------------------- /NJKWebViewProgress.podspec: -------------------------------------------------------------------------------- 1 | Pod::Spec.new do |s| 2 | s.name = "NJKWebViewProgress" 3 | s.version = "0.2.3" 4 | s.license = { :type => 'MIT', :file => 'LICENSE' } 5 | s.summary = "UIWebView progress interface." 6 | s.homepage = "https://github.com/ninjinkun/NJKWebViewProgress" 7 | s.authors = { "ninjinkun" => "ninjin@mac.com" } 8 | s.source = { :git => "https://github.com/ninjinkun/NJKWebViewProgress.git", :tag => "v#{s.version}" } 9 | s.platform = :ios, '4.3' 10 | s.requires_arc = true 11 | s.subspec 'Core' do |ss| 12 | ss.source_files = 'NJKWebViewProgress/NJKWebViewProgress.{h,m}' 13 | end 14 | s.subspec 'ProgressView' do |ss| 15 | ss.source_files = 'NJKWebViewProgress/NJKWebViewProgressView.{h,m}' 16 | end 17 | end 18 | -------------------------------------------------------------------------------- /NJKWebViewProgress/NJKWebViewProgress.h: -------------------------------------------------------------------------------- 1 | // 2 | // NJKWebViewProgress.h 3 | // 4 | // Created by Satoshi Aasano on 4/20/13. 5 | // Copyright (c) 2013 Satoshi Asano. All rights reserved. 6 | // 7 | 8 | #import 9 | #import 10 | 11 | #undef njk_weak 12 | #if __has_feature(objc_arc_weak) 13 | #define njk_weak weak 14 | #else 15 | #define njk_weak unsafe_unretained 16 | #endif 17 | 18 | extern const float NJKInitialProgressValue; 19 | extern const float NJKInteractiveProgressValue; 20 | extern const float NJKFinalProgressValue; 21 | 22 | typedef void (^NJKWebViewProgressBlock)(float progress); 23 | @protocol NJKWebViewProgressDelegate; 24 | @interface NJKWebViewProgress : NSObject 25 | @property (nonatomic, njk_weak) idprogressDelegate; 26 | @property (nonatomic, njk_weak) idwebViewProxyDelegate; 27 | @property (nonatomic, copy) NJKWebViewProgressBlock progressBlock; 28 | @property (nonatomic, readonly) float progress; // 0.0..1.0 29 | 30 | - (void)reset; 31 | @end 32 | 33 | @protocol NJKWebViewProgressDelegate 34 | - (void)webViewProgress:(NJKWebViewProgress *)webViewProgress updateProgress:(float)progress; 35 | @end 36 | 37 | -------------------------------------------------------------------------------- /NJKWebViewProgress/NJKWebViewProgress.m: -------------------------------------------------------------------------------- 1 | // 2 | // NJKWebViewProgress.m 3 | // 4 | // Created by Satoshi Aasano on 4/20/13. 5 | // Copyright (c) 2013 Satoshi Asano. All rights reserved. 6 | // 7 | 8 | #import "NJKWebViewProgress.h" 9 | 10 | NSString *completeRPCURLPath = @"/njkwebviewprogressproxy/complete"; 11 | 12 | const float NJKInitialProgressValue = 0.1f; 13 | const float NJKInteractiveProgressValue = 0.5f; 14 | const float NJKFinalProgressValue = 0.9f; 15 | 16 | @implementation NJKWebViewProgress 17 | { 18 | NSUInteger _loadingCount; 19 | NSUInteger _maxLoadCount; 20 | NSURL *_currentURL; 21 | BOOL _interactive; 22 | } 23 | 24 | - (id)init 25 | { 26 | self = [super init]; 27 | if (self) { 28 | _maxLoadCount = _loadingCount = 0; 29 | _interactive = NO; 30 | } 31 | return self; 32 | } 33 | 34 | - (void)startProgress 35 | { 36 | if (_progress < NJKInitialProgressValue) { 37 | [self setProgress:NJKInitialProgressValue]; 38 | } 39 | } 40 | 41 | - (void)incrementProgress 42 | { 43 | float progress = self.progress; 44 | float maxProgress = _interactive ? NJKFinalProgressValue : NJKInteractiveProgressValue; 45 | float remainPercent = (float)_loadingCount / (float)_maxLoadCount; 46 | float increment = (maxProgress - progress) * remainPercent; 47 | progress += increment; 48 | progress = fmin(progress, maxProgress); 49 | [self setProgress:progress]; 50 | } 51 | 52 | - (void)completeProgress 53 | { 54 | [self setProgress:1.0]; 55 | } 56 | 57 | - (void)setProgress:(float)progress 58 | { 59 | // progress should be incremental only 60 | if (progress > _progress || progress == 0) { 61 | _progress = progress; 62 | if ([_progressDelegate respondsToSelector:@selector(webViewProgress:updateProgress:)]) { 63 | [_progressDelegate webViewProgress:self updateProgress:progress]; 64 | } 65 | if (_progressBlock) { 66 | _progressBlock(progress); 67 | } 68 | } 69 | } 70 | 71 | - (void)reset 72 | { 73 | _maxLoadCount = _loadingCount = 0; 74 | _interactive = NO; 75 | [self setProgress:0.0]; 76 | } 77 | 78 | #pragma mark - 79 | #pragma mark UIWebViewDelegate 80 | 81 | - (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType 82 | { 83 | if ([request.URL.path isEqualToString:completeRPCURLPath]) { 84 | [self completeProgress]; 85 | return NO; 86 | } 87 | 88 | BOOL ret = YES; 89 | if ([_webViewProxyDelegate respondsToSelector:@selector(webView:shouldStartLoadWithRequest:navigationType:)]) { 90 | ret = [_webViewProxyDelegate webView:webView shouldStartLoadWithRequest:request navigationType:navigationType]; 91 | } 92 | 93 | BOOL isFragmentJump = NO; 94 | if (request.URL.fragment) { 95 | NSString *nonFragmentURL = [request.URL.absoluteString stringByReplacingOccurrencesOfString:[@"#" stringByAppendingString:request.URL.fragment] withString:@""]; 96 | isFragmentJump = [nonFragmentURL isEqualToString:webView.request.URL.absoluteString]; 97 | } 98 | 99 | BOOL isTopLevelNavigation = [request.mainDocumentURL isEqual:request.URL]; 100 | 101 | BOOL isHTTPOrLocalFile = [request.URL.scheme isEqualToString:@"http"] || [request.URL.scheme isEqualToString:@"https"] || [request.URL.scheme isEqualToString:@"file"]; 102 | if (ret && !isFragmentJump && isHTTPOrLocalFile && isTopLevelNavigation) { 103 | _currentURL = request.URL; 104 | [self reset]; 105 | } 106 | return ret; 107 | } 108 | 109 | - (void)webViewDidStartLoad:(UIWebView *)webView 110 | { 111 | if ([_webViewProxyDelegate respondsToSelector:@selector(webViewDidStartLoad:)]) { 112 | [_webViewProxyDelegate webViewDidStartLoad:webView]; 113 | } 114 | 115 | _loadingCount++; 116 | _maxLoadCount = fmax(_maxLoadCount, _loadingCount); 117 | 118 | [self startProgress]; 119 | } 120 | 121 | - (void)webViewDidFinishLoad:(UIWebView *)webView 122 | { 123 | if ([_webViewProxyDelegate respondsToSelector:@selector(webViewDidFinishLoad:)]) { 124 | [_webViewProxyDelegate webViewDidFinishLoad:webView]; 125 | } 126 | 127 | _loadingCount--; 128 | [self incrementProgress]; 129 | 130 | NSString *readyState = [webView stringByEvaluatingJavaScriptFromString:@"document.readyState"]; 131 | 132 | BOOL interactive = [readyState isEqualToString:@"interactive"]; 133 | if (interactive) { 134 | _interactive = YES; 135 | NSString *waitForCompleteJS = [NSString stringWithFormat:@"window.addEventListener('load',function() { var iframe = document.createElement('iframe'); iframe.style.display = 'none'; iframe.src = '%@://%@%@'; document.body.appendChild(iframe); }, false);", webView.request.mainDocumentURL.scheme, webView.request.mainDocumentURL.host, completeRPCURLPath]; 136 | [webView stringByEvaluatingJavaScriptFromString:waitForCompleteJS]; 137 | } 138 | 139 | BOOL isNotRedirect = _currentURL && [_currentURL isEqual:webView.request.mainDocumentURL]; 140 | BOOL complete = [readyState isEqualToString:@"complete"]; 141 | if (complete && isNotRedirect) { 142 | [self completeProgress]; 143 | } 144 | } 145 | 146 | - (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error 147 | { 148 | if ([_webViewProxyDelegate respondsToSelector:@selector(webView:didFailLoadWithError:)]) { 149 | [_webViewProxyDelegate webView:webView didFailLoadWithError:error]; 150 | } 151 | 152 | _loadingCount--; 153 | [self incrementProgress]; 154 | 155 | NSString *readyState = [webView stringByEvaluatingJavaScriptFromString:@"document.readyState"]; 156 | 157 | BOOL interactive = [readyState isEqualToString:@"interactive"]; 158 | if (interactive) { 159 | _interactive = YES; 160 | NSString *waitForCompleteJS = [NSString stringWithFormat:@"window.addEventListener('load',function() { var iframe = document.createElement('iframe'); iframe.style.display = 'none'; iframe.src = '%@://%@%@'; document.body.appendChild(iframe); }, false);", webView.request.mainDocumentURL.scheme, webView.request.mainDocumentURL.host, completeRPCURLPath]; 161 | [webView stringByEvaluatingJavaScriptFromString:waitForCompleteJS]; 162 | } 163 | 164 | BOOL isNotRedirect = _currentURL && [_currentURL isEqual:webView.request.mainDocumentURL]; 165 | BOOL complete = [readyState isEqualToString:@"complete"]; 166 | if ((complete && isNotRedirect) || error) { 167 | [self completeProgress]; 168 | } 169 | } 170 | 171 | #pragma mark - 172 | #pragma mark Method Forwarding 173 | // for future UIWebViewDelegate impl 174 | 175 | - (BOOL)respondsToSelector:(SEL)aSelector 176 | { 177 | if ( [super respondsToSelector:aSelector] ) 178 | return YES; 179 | 180 | if ([self.webViewProxyDelegate respondsToSelector:aSelector]) 181 | return YES; 182 | 183 | return NO; 184 | } 185 | 186 | - (NSMethodSignature *)methodSignatureForSelector:(SEL)selector 187 | { 188 | NSMethodSignature *signature = [super methodSignatureForSelector:selector]; 189 | if(!signature) { 190 | if([_webViewProxyDelegate respondsToSelector:selector]) { 191 | return [(NSObject *)_webViewProxyDelegate methodSignatureForSelector:selector]; 192 | } 193 | } 194 | return signature; 195 | } 196 | 197 | - (void)forwardInvocation:(NSInvocation*)invocation 198 | { 199 | if ([_webViewProxyDelegate respondsToSelector:[invocation selector]]) { 200 | [invocation invokeWithTarget:_webViewProxyDelegate]; 201 | } 202 | } 203 | 204 | @end 205 | -------------------------------------------------------------------------------- /NJKWebViewProgress/NJKWebViewProgressView.h: -------------------------------------------------------------------------------- 1 | // 2 | // NJKWebViewProgressView.h 3 | // iOS 7 Style WebView Progress Bar 4 | // 5 | // Created by Satoshi Aasano on 11/16/13. 6 | // Copyright (c) 2013 Satoshi Asano. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface NJKWebViewProgressView : UIView 12 | @property (nonatomic) float progress; 13 | 14 | @property (nonatomic) UIView *progressBarView; 15 | @property (nonatomic) NSTimeInterval barAnimationDuration; // default 0.1 16 | @property (nonatomic) NSTimeInterval fadeAnimationDuration; // default 0.27 17 | @property (nonatomic) NSTimeInterval fadeOutDelay; // default 0.1 18 | 19 | - (void)setProgress:(float)progress animated:(BOOL)animated; 20 | 21 | @end 22 | -------------------------------------------------------------------------------- /NJKWebViewProgress/NJKWebViewProgressView.m: -------------------------------------------------------------------------------- 1 | // 2 | // NJKWebViewProgressView.m 3 | // 4 | // Created by Satoshi Aasanoon 11/16/13. 5 | // Copyright (c) 2013 Satoshi Asano. All rights reserved. 6 | // 7 | 8 | #import "NJKWebViewProgressView.h" 9 | 10 | @implementation NJKWebViewProgressView 11 | 12 | - (id)initWithFrame:(CGRect)frame 13 | { 14 | self = [super initWithFrame:frame]; 15 | if (self) { 16 | [self configureViews]; 17 | } 18 | return self; 19 | } 20 | 21 | - (void)awakeFromNib 22 | { 23 | [super awakeFromNib]; 24 | [self configureViews]; 25 | } 26 | 27 | -(void)configureViews 28 | { 29 | self.userInteractionEnabled = NO; 30 | self.autoresizingMask = UIViewAutoresizingFlexibleWidth; 31 | _progressBarView = [[UIView alloc] initWithFrame:self.bounds]; 32 | _progressBarView.autoresizingMask = UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight; 33 | UIColor *tintColor = [UIColor colorWithRed:22.f / 255.f green:126.f / 255.f blue:251.f / 255.f alpha:1.0]; // iOS7 Safari bar color 34 | if ([UIApplication.sharedApplication.delegate.window respondsToSelector:@selector(setTintColor:)] && UIApplication.sharedApplication.delegate.window.tintColor) { 35 | tintColor = UIApplication.sharedApplication.delegate.window.tintColor; 36 | } 37 | _progressBarView.backgroundColor = tintColor; 38 | [self addSubview:_progressBarView]; 39 | 40 | _barAnimationDuration = 0.27f; 41 | _fadeAnimationDuration = 0.27f; 42 | _fadeOutDelay = 0.1f; 43 | } 44 | 45 | -(void)setProgress:(float)progress 46 | { 47 | [self setProgress:progress animated:NO]; 48 | } 49 | 50 | - (void)setProgress:(float)progress animated:(BOOL)animated 51 | { 52 | BOOL isGrowing = progress > 0.0; 53 | [UIView animateWithDuration:(isGrowing && animated) ? _barAnimationDuration : 0.0 delay:0 options:UIViewAnimationOptionCurveEaseInOut animations:^{ 54 | CGRect frame = _progressBarView.frame; 55 | frame.size.width = progress * self.bounds.size.width; 56 | _progressBarView.frame = frame; 57 | } completion:nil]; 58 | 59 | if (progress >= 1.0) { 60 | [UIView animateWithDuration:animated ? _fadeAnimationDuration : 0.0 delay:_fadeOutDelay options:UIViewAnimationOptionCurveEaseInOut animations:^{ 61 | _progressBarView.alpha = 0.0; 62 | } completion:^(BOOL completed){ 63 | CGRect frame = _progressBarView.frame; 64 | frame.size.width = 0; 65 | _progressBarView.frame = frame; 66 | }]; 67 | } 68 | else { 69 | [UIView animateWithDuration:animated ? _fadeAnimationDuration : 0.0 delay:0.0 options:UIViewAnimationOptionCurveEaseInOut animations:^{ 70 | _progressBarView.alpha = 1.0; 71 | } completion:nil]; 72 | } 73 | } 74 | 75 | @end 76 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # NJKWebViewProgress 2 | NJKWebViewProgress is a progress interface library for UIWebView. Currently, UIWebView doesn't have official progress interface. You can implement progress bar for your in-app browser using this module. 3 | 4 | iOS ScreenShot 1 5 | 6 | NJKWebViewProgress doesn't use CocoaTouch's private methods. It's AppStore safe. 7 | 8 | # Used in Production 9 | - [Yahoo! JAPAN](https://itunes.apple.com/app/yahoo!-japan/id299147843?mt=8) 10 | - [Facebook](https://itunes.apple.com/app/facebook/id284882215?mt=8‎) 11 | 12 | # Requirements 13 | - iOS 4.3 or later 14 | - ARC 15 | 16 | # Usage 17 | Instance `NJKWebViewProgress` and set `UIWebViewDelegate`. If you set `webViewProxyDelegate`, `NJKWebViewProgress` should perform as a proxy object. 18 | 19 | ```objc 20 | _progressProxy = [[NJKWebViewProgress alloc] init]; // instance variable 21 | webView.delegate = _progressProxy; 22 | _progressProxy.webViewProxyDelegate = self; 23 | _progressProxy.progressDelegate = self; 24 | ``` 25 | 26 | When UIWebView start loading, `NJKWebViewProgress` call delegate method and block with progress. 27 | ```objc 28 | -(void)webViewProgress:(NJKWebViewProgress *)webViewProgress updateProgress:(float)progress 29 | { 30 | [progressView setProgress:progress animated:NO]; 31 | } 32 | ``` 33 | 34 | ```objc 35 | progressProxy.progressBlock = ^(float progress) { 36 | [progressView setProgress:progress animated:NO]; 37 | }; 38 | ``` 39 | 40 | You can determine the current state of the document by comparing the `progress` value to one of the provided constants: 41 | 42 | ```objc 43 | -(void)webViewProgress:(NJKWebViewProgress *)webViewProgress updateProgress:(float)progress 44 | { 45 | if (progress == NJKInteractiveProgressValue) { 46 | // The web view has finished parsing the document, 47 | // but is still loading sub-resources 48 | } 49 | } 50 | ``` 51 | 52 | This repository contains iOS 7 Safari style bar `NJKWebViewProgressView`. You can choose `NJKWebViewProgressView`, `UIProgressView` or your custom bar. 53 | 54 | # Install 55 | ## CocoaPods 56 | 57 | ``` 58 | pod 'NJKWebViewProgress' 59 | ``` 60 | 61 | # License 62 | [Apache]: http://www.apache.org/licenses/LICENSE-2.0 63 | [MIT]: http://www.opensource.org/licenses/mit-license.php 64 | [GPL]: http://www.gnu.org/licenses/gpl.html 65 | [BSD]: http://opensource.org/licenses/bsd-license.php 66 | [MIT license][MIT]. 67 | --------------------------------------------------------------------------------