├── .gitignore ├── BRYParseKeyboardNotification.podspec.json ├── BRYParseKeyboardNotification.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ └── contents.xcworkspacedata └── xcuserdata │ └── Bryan.xcuserdatad │ └── xcschemes │ ├── BRYParseKeyboardNotification.xcscheme │ └── xcschememanagement.plist ├── Classes ├── BRYParseKeyboardNotification.h └── BRYParseKeyboardNotification.m ├── LICENSE └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | .DS_Store 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 | profile 14 | *.moved-aside 15 | DerivedData 16 | .idea/ 17 | *.hmap 18 | *.xccheckout 19 | 20 | #CocoaPods 21 | Pods 22 | -------------------------------------------------------------------------------- /BRYParseKeyboardNotification.podspec.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "BRYParseKeyboardNotification", 3 | "version": "1.0.1", 4 | "summary": "Parses the useful parts out of a keyboard will show/hide notification", 5 | "homepage": "http://github.com/irace/BRYParseKeyboardNotification", 6 | "license": { 7 | "type": "MIT", 8 | "file": "LICENSE" 9 | }, 10 | "authors": { 11 | "Bryan Irace": "bryan@irace.me" 12 | }, 13 | "platforms": { 14 | "ios": "7.0" 15 | }, 16 | "source": { 17 | "git": "https://github.com/irace/BRYParseKeyboardNotification.git", 18 | "tag": "1.0.1" 19 | }, 20 | "source_files": "Classes", 21 | "frameworks": [ 22 | "Foundation", 23 | "UIKit" 24 | ], 25 | "requires_arc": true 26 | } 27 | -------------------------------------------------------------------------------- /BRYParseKeyboardNotification.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 939C33C51876374B00E934B8 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 939C33C41876374B00E934B8 /* Foundation.framework */; }; 11 | 939C33EC18763BAF00E934B8 /* BRYParseKeyboardNotification.m in Sources */ = {isa = PBXBuildFile; fileRef = 939C33EB18763BAF00E934B8 /* BRYParseKeyboardNotification.m */; }; 12 | /* End PBXBuildFile section */ 13 | 14 | /* Begin PBXCopyFilesBuildPhase section */ 15 | 939C33BF1876374B00E934B8 /* CopyFiles */ = { 16 | isa = PBXCopyFilesBuildPhase; 17 | buildActionMask = 2147483647; 18 | dstPath = "include/$(PRODUCT_NAME)"; 19 | dstSubfolderSpec = 16; 20 | files = ( 21 | ); 22 | runOnlyForDeploymentPostprocessing = 0; 23 | }; 24 | /* End PBXCopyFilesBuildPhase section */ 25 | 26 | /* Begin PBXFileReference section */ 27 | 939C33C11876374B00E934B8 /* libBRYParseKeyboardNotification.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libBRYParseKeyboardNotification.a; sourceTree = BUILT_PRODUCTS_DIR; }; 28 | 939C33C41876374B00E934B8 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; 29 | 939C33D21876374B00E934B8 /* XCTest.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = XCTest.framework; path = Library/Frameworks/XCTest.framework; sourceTree = DEVELOPER_DIR; }; 30 | 939C33D51876374B00E934B8 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = Library/Frameworks/UIKit.framework; sourceTree = DEVELOPER_DIR; }; 31 | 939C33EA18763BAF00E934B8 /* BRYParseKeyboardNotification.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BRYParseKeyboardNotification.h; sourceTree = ""; }; 32 | 939C33EB18763BAF00E934B8 /* BRYParseKeyboardNotification.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BRYParseKeyboardNotification.m; sourceTree = ""; }; 33 | /* End PBXFileReference section */ 34 | 35 | /* Begin PBXFrameworksBuildPhase section */ 36 | 939C33BE1876374B00E934B8 /* Frameworks */ = { 37 | isa = PBXFrameworksBuildPhase; 38 | buildActionMask = 2147483647; 39 | files = ( 40 | 939C33C51876374B00E934B8 /* Foundation.framework in Frameworks */, 41 | ); 42 | runOnlyForDeploymentPostprocessing = 0; 43 | }; 44 | /* End PBXFrameworksBuildPhase section */ 45 | 46 | /* Begin PBXGroup section */ 47 | 932700D4187705EB00E38FD6 /* Classes */ = { 48 | isa = PBXGroup; 49 | children = ( 50 | 939C33EA18763BAF00E934B8 /* BRYParseKeyboardNotification.h */, 51 | 939C33EB18763BAF00E934B8 /* BRYParseKeyboardNotification.m */, 52 | ); 53 | path = Classes; 54 | sourceTree = ""; 55 | }; 56 | 939C33B81876374B00E934B8 = { 57 | isa = PBXGroup; 58 | children = ( 59 | 932700D4187705EB00E38FD6 /* Classes */, 60 | 939C33C31876374B00E934B8 /* Frameworks */, 61 | 939C33C21876374B00E934B8 /* Products */, 62 | ); 63 | sourceTree = ""; 64 | }; 65 | 939C33C21876374B00E934B8 /* Products */ = { 66 | isa = PBXGroup; 67 | children = ( 68 | 939C33C11876374B00E934B8 /* libBRYParseKeyboardNotification.a */, 69 | ); 70 | name = Products; 71 | sourceTree = ""; 72 | }; 73 | 939C33C31876374B00E934B8 /* Frameworks */ = { 74 | isa = PBXGroup; 75 | children = ( 76 | 939C33C41876374B00E934B8 /* Foundation.framework */, 77 | 939C33D21876374B00E934B8 /* XCTest.framework */, 78 | 939C33D51876374B00E934B8 /* UIKit.framework */, 79 | ); 80 | name = Frameworks; 81 | sourceTree = ""; 82 | }; 83 | /* End PBXGroup section */ 84 | 85 | /* Begin PBXNativeTarget section */ 86 | 939C33C01876374B00E934B8 /* BRYParseKeyboardNotification */ = { 87 | isa = PBXNativeTarget; 88 | buildConfigurationList = 939C33E41876374B00E934B8 /* Build configuration list for PBXNativeTarget "BRYParseKeyboardNotification" */; 89 | buildPhases = ( 90 | 939C33BD1876374B00E934B8 /* Sources */, 91 | 939C33BE1876374B00E934B8 /* Frameworks */, 92 | 939C33BF1876374B00E934B8 /* CopyFiles */, 93 | ); 94 | buildRules = ( 95 | ); 96 | dependencies = ( 97 | ); 98 | name = BRYParseKeyboardNotification; 99 | productName = BRYParseKeyboardNotification; 100 | productReference = 939C33C11876374B00E934B8 /* libBRYParseKeyboardNotification.a */; 101 | productType = "com.apple.product-type.library.static"; 102 | }; 103 | /* End PBXNativeTarget section */ 104 | 105 | /* Begin PBXProject section */ 106 | 939C33B91876374B00E934B8 /* Project object */ = { 107 | isa = PBXProject; 108 | attributes = { 109 | LastUpgradeCheck = 0500; 110 | ORGANIZATIONNAME = "Bryan Irace"; 111 | }; 112 | buildConfigurationList = 939C33BC1876374B00E934B8 /* Build configuration list for PBXProject "BRYParseKeyboardNotification" */; 113 | compatibilityVersion = "Xcode 3.2"; 114 | developmentRegion = English; 115 | hasScannedForEncodings = 0; 116 | knownRegions = ( 117 | en, 118 | ); 119 | mainGroup = 939C33B81876374B00E934B8; 120 | productRefGroup = 939C33C21876374B00E934B8 /* Products */; 121 | projectDirPath = ""; 122 | projectRoot = ""; 123 | targets = ( 124 | 939C33C01876374B00E934B8 /* BRYParseKeyboardNotification */, 125 | ); 126 | }; 127 | /* End PBXProject section */ 128 | 129 | /* Begin PBXSourcesBuildPhase section */ 130 | 939C33BD1876374B00E934B8 /* Sources */ = { 131 | isa = PBXSourcesBuildPhase; 132 | buildActionMask = 2147483647; 133 | files = ( 134 | 939C33EC18763BAF00E934B8 /* BRYParseKeyboardNotification.m in Sources */, 135 | ); 136 | runOnlyForDeploymentPostprocessing = 0; 137 | }; 138 | /* End PBXSourcesBuildPhase section */ 139 | 140 | /* Begin XCBuildConfiguration section */ 141 | 939C33E21876374B00E934B8 /* Debug */ = { 142 | isa = XCBuildConfiguration; 143 | buildSettings = { 144 | ALWAYS_SEARCH_USER_PATHS = NO; 145 | ARCHS = "$(ARCHS_STANDARD_INCLUDING_64_BIT)"; 146 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 147 | CLANG_CXX_LIBRARY = "libc++"; 148 | CLANG_ENABLE_MODULES = YES; 149 | CLANG_ENABLE_OBJC_ARC = YES; 150 | CLANG_WARN_BOOL_CONVERSION = YES; 151 | CLANG_WARN_CONSTANT_CONVERSION = YES; 152 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 153 | CLANG_WARN_EMPTY_BODY = YES; 154 | CLANG_WARN_ENUM_CONVERSION = YES; 155 | CLANG_WARN_INT_CONVERSION = YES; 156 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 157 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 158 | COPY_PHASE_STRIP = NO; 159 | GCC_C_LANGUAGE_STANDARD = gnu99; 160 | GCC_DYNAMIC_NO_PIC = NO; 161 | GCC_OPTIMIZATION_LEVEL = 0; 162 | GCC_PREPROCESSOR_DEFINITIONS = ( 163 | "DEBUG=1", 164 | "$(inherited)", 165 | ); 166 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 167 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 168 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 169 | GCC_WARN_UNDECLARED_SELECTOR = YES; 170 | GCC_WARN_UNINITIALIZED_AUTOS = YES; 171 | GCC_WARN_UNUSED_FUNCTION = YES; 172 | GCC_WARN_UNUSED_VARIABLE = YES; 173 | IPHONEOS_DEPLOYMENT_TARGET = 7.0; 174 | ONLY_ACTIVE_ARCH = YES; 175 | SDKROOT = iphoneos; 176 | }; 177 | name = Debug; 178 | }; 179 | 939C33E31876374B00E934B8 /* Release */ = { 180 | isa = XCBuildConfiguration; 181 | buildSettings = { 182 | ALWAYS_SEARCH_USER_PATHS = NO; 183 | ARCHS = "$(ARCHS_STANDARD_INCLUDING_64_BIT)"; 184 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 185 | CLANG_CXX_LIBRARY = "libc++"; 186 | CLANG_ENABLE_MODULES = YES; 187 | CLANG_ENABLE_OBJC_ARC = YES; 188 | CLANG_WARN_BOOL_CONVERSION = YES; 189 | CLANG_WARN_CONSTANT_CONVERSION = YES; 190 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 191 | CLANG_WARN_EMPTY_BODY = YES; 192 | CLANG_WARN_ENUM_CONVERSION = YES; 193 | CLANG_WARN_INT_CONVERSION = YES; 194 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 195 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 196 | COPY_PHASE_STRIP = YES; 197 | ENABLE_NS_ASSERTIONS = NO; 198 | GCC_C_LANGUAGE_STANDARD = gnu99; 199 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 200 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 201 | GCC_WARN_UNDECLARED_SELECTOR = YES; 202 | GCC_WARN_UNINITIALIZED_AUTOS = YES; 203 | GCC_WARN_UNUSED_FUNCTION = YES; 204 | GCC_WARN_UNUSED_VARIABLE = YES; 205 | IPHONEOS_DEPLOYMENT_TARGET = 7.0; 206 | SDKROOT = iphoneos; 207 | VALIDATE_PRODUCT = YES; 208 | }; 209 | name = Release; 210 | }; 211 | 939C33E51876374B00E934B8 /* Debug */ = { 212 | isa = XCBuildConfiguration; 213 | buildSettings = { 214 | DSTROOT = /tmp/BRYParseKeyboardNotification.dst; 215 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 216 | OTHER_LDFLAGS = "-ObjC"; 217 | PRODUCT_NAME = "$(TARGET_NAME)"; 218 | SKIP_INSTALL = YES; 219 | }; 220 | name = Debug; 221 | }; 222 | 939C33E61876374B00E934B8 /* Release */ = { 223 | isa = XCBuildConfiguration; 224 | buildSettings = { 225 | DSTROOT = /tmp/BRYParseKeyboardNotification.dst; 226 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 227 | OTHER_LDFLAGS = "-ObjC"; 228 | PRODUCT_NAME = "$(TARGET_NAME)"; 229 | SKIP_INSTALL = YES; 230 | }; 231 | name = Release; 232 | }; 233 | /* End XCBuildConfiguration section */ 234 | 235 | /* Begin XCConfigurationList section */ 236 | 939C33BC1876374B00E934B8 /* Build configuration list for PBXProject "BRYParseKeyboardNotification" */ = { 237 | isa = XCConfigurationList; 238 | buildConfigurations = ( 239 | 939C33E21876374B00E934B8 /* Debug */, 240 | 939C33E31876374B00E934B8 /* Release */, 241 | ); 242 | defaultConfigurationIsVisible = 0; 243 | defaultConfigurationName = Release; 244 | }; 245 | 939C33E41876374B00E934B8 /* Build configuration list for PBXNativeTarget "BRYParseKeyboardNotification" */ = { 246 | isa = XCConfigurationList; 247 | buildConfigurations = ( 248 | 939C33E51876374B00E934B8 /* Debug */, 249 | 939C33E61876374B00E934B8 /* Release */, 250 | ); 251 | defaultConfigurationIsVisible = 0; 252 | defaultConfigurationName = Release; 253 | }; 254 | /* End XCConfigurationList section */ 255 | }; 256 | rootObject = 939C33B91876374B00E934B8 /* Project object */; 257 | } 258 | -------------------------------------------------------------------------------- /BRYParseKeyboardNotification.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /BRYParseKeyboardNotification.xcodeproj/xcuserdata/Bryan.xcuserdatad/xcschemes/BRYParseKeyboardNotification.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 33 | 39 | 40 | 41 | 42 | 43 | 52 | 53 | 54 | 55 | 61 | 62 | 64 | 65 | 68 | 69 | 70 | -------------------------------------------------------------------------------- /BRYParseKeyboardNotification.xcodeproj/xcuserdata/Bryan.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | BRYParseKeyboardNotification.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | 939C33C01876374B00E934B8 16 | 17 | primary 18 | 19 | 20 | 939C33D01876374B00E934B8 21 | 22 | primary 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /Classes/BRYParseKeyboardNotification.h: -------------------------------------------------------------------------------- 1 | // 2 | // BRYParseKeyboardNotification.h 3 | // BRYParseKeyboardNotification 4 | // 5 | // Created by Bryan Irace on 1/2/14. 6 | // Copyright (c) 2014 Bryan Irace. All rights reserved. 7 | // 8 | 9 | @import Foundation; 10 | @import UIKit; 11 | 12 | void BRYParseKeyboardNotification(NSNotification *notification, void(^callback)(NSTimeInterval keyboardAnimationDuration, CGFloat keyboardHeight, UIViewAnimationOptions keyboardAnimationOptions)); 13 | -------------------------------------------------------------------------------- /Classes/BRYParseKeyboardNotification.m: -------------------------------------------------------------------------------- 1 | // 2 | // BRYParseKeyboardNotification.m 3 | // BRYParseKeyboardNotification 4 | // 5 | // Created by Bryan Irace on 1/2/14. 6 | // Copyright (c) 2014 Bryan Irace. All rights reserved. 7 | // 8 | 9 | #import "BRYParseKeyboardNotification.h" 10 | 11 | static inline BOOL versionIsLessThan(NSString *version) { 12 | return [[[UIDevice currentDevice] systemVersion] compare:version options:NSNumericSearch] == NSOrderedAscending; 13 | } 14 | 15 | void BRYParseKeyboardNotification(NSNotification *notification, void(^callback)(NSTimeInterval keyboardAnimationDuration, CGFloat keyboardHeight, UIViewAnimationOptions keyboardAnimationOptions)) { 16 | NSDictionary *userInfo = [notification userInfo]; 17 | 18 | NSTimeInterval duration = [userInfo[UIKeyboardAnimationDurationUserInfoKey] doubleValue]; 19 | 20 | // Convert animation curve to animation options: https://devforums.apple.com/message/878410#878410 21 | UIViewAnimationOptions options = [userInfo[UIKeyboardAnimationCurveUserInfoKey] integerValue] << 16; 22 | 23 | CGRect keyboardEndFrame = [userInfo[UIKeyboardFrameEndUserInfoKey] CGRectValue]; 24 | 25 | CGFloat height = CGRectGetHeight(keyboardEndFrame); 26 | 27 | if (versionIsLessThan(@"8.0")) { 28 | if (UIInterfaceOrientationIsLandscape([[UIApplication sharedApplication] statusBarOrientation])) { 29 | height = CGRectGetWidth(keyboardEndFrame); 30 | } 31 | } 32 | 33 | if (callback) { 34 | callback(duration, height, options); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Bryan Irace 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software is furnished to do so, 10 | 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, FITNESS 17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # BRYParseKeyboardNotification 2 | 3 | A function that parses the useful parts out of a keyboard will appear/disappear notification. 4 | 5 | ## Installation 6 | 7 | Via [CocoaPods](http://cocoapods.org), of course: 8 | 9 | pod "BRYParseKeyboardNotification" 10 | 11 | ## Usage 12 | 13 | ```objective-c 14 | - (void)keyboardWillShow:(NSNotification *)notification { 15 | BRYParseKeyboardNotification(notification, ^(NSTimeInterval keyboardAnimationDuration, CGFloat keyboardHeight, UIViewAnimationOptions keyboardAnimationOptions) { 16 | [UIView animateWithDuration:keyboardAnimationDuration delay:0 options:keyboardAnimationOptions animations:^{ 17 | someView.frameHeight -= keyboardHeight; 18 | }]; 19 | }); 20 | } 21 | ``` 22 | 23 | ## License 24 | Available for use under the MIT license: [http://bryan.mit-license.org](http://bryan.mit-license.org) 25 | --------------------------------------------------------------------------------