├── .gitignore ├── KIZBehavior.podspec ├── KIZBehaviorDemo.xcodeproj ├── project.pbxproj └── project.xcworkspace │ └── contents.xcworkspacedata ├── KIZBehaviorDemo ├── AppDelegate.h ├── AppDelegate.m ├── Assets.xcassets │ ├── AppIcon.appiconset │ │ └── Contents.json │ ├── Contents.json │ ├── hashiqi.imageset │ │ ├── Contents.json │ │ └── dog.png │ └── share.imageset │ │ ├── Contents.json │ │ ├── share_pink_hollow@2x.png │ │ └── share_pink_hollow@3x.png ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard ├── Classes │ ├── CharacterLimit │ │ ├── KIZCharacterLimitBehavior.h │ │ └── KIZCharacterLimitBehavior.m │ ├── KIZBehavior.h │ ├── KIZBehavior.m │ ├── KIZMultipleProxyBehavior.h │ ├── KIZMultipleProxyBehavior.m │ ├── NavigationBar │ │ ├── KIZNavBarGradientBehavior.h │ │ ├── KIZNavBarGradientBehavior.m │ │ ├── UINavigationBar+KIZExtention.h │ │ └── UINavigationBar+KIZExtention.m │ └── ParallaxHeader │ │ ├── KIZParallaxHeaderBehavior.h │ │ └── KIZParallaxHeaderBehavior.m ├── DemoForCode.h ├── DemoForCode.m ├── Info.plist ├── ViewController.h ├── ViewController.m └── main.m ├── KIZBehaviorDemoTests ├── Info.plist └── KIZBehaviorDemoTests.m ├── KIZBehaviorDemoUITests ├── Info.plist └── KIZBehaviorDemoUITests.m ├── LICENSE └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | .DS_store 4 | 5 | build/ 6 | *.pbxuser 7 | !default.pbxuser 8 | *.mode1v3 9 | !default.mode1v3 10 | *.mode2v3 11 | !default.mode2v3 12 | *.perspectivev3 13 | !default.perspectivev3 14 | xcuserdata 15 | *.xccheckout 16 | *.moved-aside 17 | DerivedData 18 | *.hmap 19 | *.ipa 20 | *.xcuserstate 21 | 22 | # CocoaPods 23 | # 24 | # We recommend against adding the Pods directory to your .gitignore. However 25 | # you should judge for yourself, the pros and cons are mentioned at: 26 | # http://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control 27 | # 28 | #Pods/ 29 | -------------------------------------------------------------------------------- /KIZBehavior.podspec: -------------------------------------------------------------------------------- 1 | Pod::Spec.new do |s| 2 | 3 | s.name = "KIZBehavior" 4 | s.version = "0.0.1" 5 | s.summary = "使用Storyboard 0代码集成的一些小功能" 6 | 7 | s.description = <<-DESC 8 | 使用Storyboard 0代码集成的一些小功能。 9 | DESC 10 | 11 | s.homepage = "https://github.com/zziking/KIZBehavior" 12 | s.screenshots = "http://7xjsf4.com1.z0.glb.clouddn.com/git_KIZBehavior_parallax_nav.gif" 13 | 14 | 15 | s.license = { :type => 'MIT', :file => 'LICENSE' } 16 | 17 | s.author = { "kingizz" => "admin@fuckipad.com" } 18 | 19 | s.platform = :ios 20 | s.platform = :ios, "6.0" 21 | 22 | s.source = { :git => "https://github.com/zziking/KIZBehavior.git", :tag => "v0.0.1" } 23 | s.source_files = "KIZBehaviorDemo/Classes/**/*.{h,m}" 24 | 25 | s.requires_arc = true 26 | 27 | end 28 | -------------------------------------------------------------------------------- /KIZBehaviorDemo.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 188C0E411DEE8B000011B9B1 /* DemoForCode.m in Sources */ = {isa = PBXBuildFile; fileRef = 188C0E401DEE8B000011B9B1 /* DemoForCode.m */; }; 11 | 44E05D921BEE4B2500E9E8D0 /* KIZCharacterLimitBehavior.m in Sources */ = {isa = PBXBuildFile; fileRef = 44E05D911BEE4B2500E9E8D0 /* KIZCharacterLimitBehavior.m */; }; 12 | 44F9B0D41BE45242009A0914 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 44F9B0D31BE45242009A0914 /* main.m */; }; 13 | 44F9B0D71BE45242009A0914 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 44F9B0D61BE45242009A0914 /* AppDelegate.m */; }; 14 | 44F9B0DA1BE45242009A0914 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 44F9B0D91BE45242009A0914 /* ViewController.m */; }; 15 | 44F9B0DD1BE45242009A0914 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 44F9B0DB1BE45242009A0914 /* Main.storyboard */; }; 16 | 44F9B0DF1BE45242009A0914 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 44F9B0DE1BE45242009A0914 /* Assets.xcassets */; }; 17 | 44F9B0E21BE45242009A0914 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 44F9B0E01BE45242009A0914 /* LaunchScreen.storyboard */; }; 18 | 44F9B0ED1BE45242009A0914 /* KIZBehaviorDemoTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 44F9B0EC1BE45242009A0914 /* KIZBehaviorDemoTests.m */; }; 19 | 44F9B0F81BE45242009A0914 /* KIZBehaviorDemoUITests.m in Sources */ = {isa = PBXBuildFile; fileRef = 44F9B0F71BE45242009A0914 /* KIZBehaviorDemoUITests.m */; }; 20 | 44F9B1121BE452C7009A0914 /* KIZBehavior.m in Sources */ = {isa = PBXBuildFile; fileRef = 44F9B1071BE452C7009A0914 /* KIZBehavior.m */; }; 21 | 44F9B1131BE452C7009A0914 /* KIZMultipleProxyBehavior.m in Sources */ = {isa = PBXBuildFile; fileRef = 44F9B1091BE452C7009A0914 /* KIZMultipleProxyBehavior.m */; }; 22 | 44F9B1141BE452C7009A0914 /* KIZNavBarGradientBehavior.m in Sources */ = {isa = PBXBuildFile; fileRef = 44F9B10C1BE452C7009A0914 /* KIZNavBarGradientBehavior.m */; }; 23 | 44F9B1151BE452C7009A0914 /* UINavigationBar+KIZExtention.m in Sources */ = {isa = PBXBuildFile; fileRef = 44F9B10E1BE452C7009A0914 /* UINavigationBar+KIZExtention.m */; }; 24 | 44F9B1161BE452C7009A0914 /* KIZParallaxHeaderBehavior.m in Sources */ = {isa = PBXBuildFile; fileRef = 44F9B1111BE452C7009A0914 /* KIZParallaxHeaderBehavior.m */; }; 25 | /* End PBXBuildFile section */ 26 | 27 | /* Begin PBXContainerItemProxy section */ 28 | 44F9B0E91BE45242009A0914 /* PBXContainerItemProxy */ = { 29 | isa = PBXContainerItemProxy; 30 | containerPortal = 44F9B0C71BE45242009A0914 /* Project object */; 31 | proxyType = 1; 32 | remoteGlobalIDString = 44F9B0CE1BE45242009A0914; 33 | remoteInfo = KIZBehaviorDemo; 34 | }; 35 | 44F9B0F41BE45242009A0914 /* PBXContainerItemProxy */ = { 36 | isa = PBXContainerItemProxy; 37 | containerPortal = 44F9B0C71BE45242009A0914 /* Project object */; 38 | proxyType = 1; 39 | remoteGlobalIDString = 44F9B0CE1BE45242009A0914; 40 | remoteInfo = KIZBehaviorDemo; 41 | }; 42 | /* End PBXContainerItemProxy section */ 43 | 44 | /* Begin PBXFileReference section */ 45 | 188C0E3F1DEE8B000011B9B1 /* DemoForCode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DemoForCode.h; sourceTree = ""; }; 46 | 188C0E401DEE8B000011B9B1 /* DemoForCode.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DemoForCode.m; sourceTree = ""; }; 47 | 44E05D901BEE4B2500E9E8D0 /* KIZCharacterLimitBehavior.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KIZCharacterLimitBehavior.h; sourceTree = ""; }; 48 | 44E05D911BEE4B2500E9E8D0 /* KIZCharacterLimitBehavior.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KIZCharacterLimitBehavior.m; sourceTree = ""; }; 49 | 44F9B0CF1BE45242009A0914 /* KIZBehaviorDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = KIZBehaviorDemo.app; sourceTree = BUILT_PRODUCTS_DIR; }; 50 | 44F9B0D31BE45242009A0914 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 51 | 44F9B0D51BE45242009A0914 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 52 | 44F9B0D61BE45242009A0914 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 53 | 44F9B0D81BE45242009A0914 /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; 54 | 44F9B0D91BE45242009A0914 /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; 55 | 44F9B0DC1BE45242009A0914 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 56 | 44F9B0DE1BE45242009A0914 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 57 | 44F9B0E11BE45242009A0914 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 58 | 44F9B0E31BE45242009A0914 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 59 | 44F9B0E81BE45242009A0914 /* KIZBehaviorDemoTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = KIZBehaviorDemoTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 60 | 44F9B0EC1BE45242009A0914 /* KIZBehaviorDemoTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = KIZBehaviorDemoTests.m; sourceTree = ""; }; 61 | 44F9B0EE1BE45242009A0914 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 62 | 44F9B0F31BE45242009A0914 /* KIZBehaviorDemoUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = KIZBehaviorDemoUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 63 | 44F9B0F71BE45242009A0914 /* KIZBehaviorDemoUITests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = KIZBehaviorDemoUITests.m; sourceTree = ""; }; 64 | 44F9B0F91BE45242009A0914 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 65 | 44F9B1061BE452C7009A0914 /* KIZBehavior.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KIZBehavior.h; sourceTree = ""; }; 66 | 44F9B1071BE452C7009A0914 /* KIZBehavior.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KIZBehavior.m; sourceTree = ""; }; 67 | 44F9B1081BE452C7009A0914 /* KIZMultipleProxyBehavior.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KIZMultipleProxyBehavior.h; sourceTree = ""; }; 68 | 44F9B1091BE452C7009A0914 /* KIZMultipleProxyBehavior.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KIZMultipleProxyBehavior.m; sourceTree = ""; }; 69 | 44F9B10B1BE452C7009A0914 /* KIZNavBarGradientBehavior.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KIZNavBarGradientBehavior.h; sourceTree = ""; }; 70 | 44F9B10C1BE452C7009A0914 /* KIZNavBarGradientBehavior.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KIZNavBarGradientBehavior.m; sourceTree = ""; }; 71 | 44F9B10D1BE452C7009A0914 /* UINavigationBar+KIZExtention.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UINavigationBar+KIZExtention.h"; sourceTree = ""; }; 72 | 44F9B10E1BE452C7009A0914 /* UINavigationBar+KIZExtention.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UINavigationBar+KIZExtention.m"; sourceTree = ""; }; 73 | 44F9B1101BE452C7009A0914 /* KIZParallaxHeaderBehavior.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KIZParallaxHeaderBehavior.h; sourceTree = ""; }; 74 | 44F9B1111BE452C7009A0914 /* KIZParallaxHeaderBehavior.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KIZParallaxHeaderBehavior.m; sourceTree = ""; }; 75 | /* End PBXFileReference section */ 76 | 77 | /* Begin PBXFrameworksBuildPhase section */ 78 | 44F9B0CC1BE45242009A0914 /* Frameworks */ = { 79 | isa = PBXFrameworksBuildPhase; 80 | buildActionMask = 2147483647; 81 | files = ( 82 | ); 83 | runOnlyForDeploymentPostprocessing = 0; 84 | }; 85 | 44F9B0E51BE45242009A0914 /* Frameworks */ = { 86 | isa = PBXFrameworksBuildPhase; 87 | buildActionMask = 2147483647; 88 | files = ( 89 | ); 90 | runOnlyForDeploymentPostprocessing = 0; 91 | }; 92 | 44F9B0F01BE45242009A0914 /* Frameworks */ = { 93 | isa = PBXFrameworksBuildPhase; 94 | buildActionMask = 2147483647; 95 | files = ( 96 | ); 97 | runOnlyForDeploymentPostprocessing = 0; 98 | }; 99 | /* End PBXFrameworksBuildPhase section */ 100 | 101 | /* Begin PBXGroup section */ 102 | 44E05D8F1BEE4AF800E9E8D0 /* CharacterLimit */ = { 103 | isa = PBXGroup; 104 | children = ( 105 | 44E05D901BEE4B2500E9E8D0 /* KIZCharacterLimitBehavior.h */, 106 | 44E05D911BEE4B2500E9E8D0 /* KIZCharacterLimitBehavior.m */, 107 | ); 108 | path = CharacterLimit; 109 | sourceTree = ""; 110 | }; 111 | 44F9B0C61BE45242009A0914 = { 112 | isa = PBXGroup; 113 | children = ( 114 | 44F9B0D11BE45242009A0914 /* KIZBehaviorDemo */, 115 | 44F9B0EB1BE45242009A0914 /* KIZBehaviorDemoTests */, 116 | 44F9B0F61BE45242009A0914 /* KIZBehaviorDemoUITests */, 117 | 44F9B0D01BE45242009A0914 /* Products */, 118 | ); 119 | sourceTree = ""; 120 | }; 121 | 44F9B0D01BE45242009A0914 /* Products */ = { 122 | isa = PBXGroup; 123 | children = ( 124 | 44F9B0CF1BE45242009A0914 /* KIZBehaviorDemo.app */, 125 | 44F9B0E81BE45242009A0914 /* KIZBehaviorDemoTests.xctest */, 126 | 44F9B0F31BE45242009A0914 /* KIZBehaviorDemoUITests.xctest */, 127 | ); 128 | name = Products; 129 | sourceTree = ""; 130 | }; 131 | 44F9B0D11BE45242009A0914 /* KIZBehaviorDemo */ = { 132 | isa = PBXGroup; 133 | children = ( 134 | 44F9B1051BE452C7009A0914 /* Classes */, 135 | 44F9B0D51BE45242009A0914 /* AppDelegate.h */, 136 | 44F9B0D61BE45242009A0914 /* AppDelegate.m */, 137 | 44F9B0D81BE45242009A0914 /* ViewController.h */, 138 | 44F9B0D91BE45242009A0914 /* ViewController.m */, 139 | 188C0E3F1DEE8B000011B9B1 /* DemoForCode.h */, 140 | 188C0E401DEE8B000011B9B1 /* DemoForCode.m */, 141 | 44F9B0DB1BE45242009A0914 /* Main.storyboard */, 142 | 44F9B0DE1BE45242009A0914 /* Assets.xcassets */, 143 | 44F9B0E01BE45242009A0914 /* LaunchScreen.storyboard */, 144 | 44F9B0E31BE45242009A0914 /* Info.plist */, 145 | 44F9B0D21BE45242009A0914 /* Supporting Files */, 146 | ); 147 | path = KIZBehaviorDemo; 148 | sourceTree = ""; 149 | }; 150 | 44F9B0D21BE45242009A0914 /* Supporting Files */ = { 151 | isa = PBXGroup; 152 | children = ( 153 | 44F9B0D31BE45242009A0914 /* main.m */, 154 | ); 155 | name = "Supporting Files"; 156 | sourceTree = ""; 157 | }; 158 | 44F9B0EB1BE45242009A0914 /* KIZBehaviorDemoTests */ = { 159 | isa = PBXGroup; 160 | children = ( 161 | 44F9B0EC1BE45242009A0914 /* KIZBehaviorDemoTests.m */, 162 | 44F9B0EE1BE45242009A0914 /* Info.plist */, 163 | ); 164 | path = KIZBehaviorDemoTests; 165 | sourceTree = ""; 166 | }; 167 | 44F9B0F61BE45242009A0914 /* KIZBehaviorDemoUITests */ = { 168 | isa = PBXGroup; 169 | children = ( 170 | 44F9B0F71BE45242009A0914 /* KIZBehaviorDemoUITests.m */, 171 | 44F9B0F91BE45242009A0914 /* Info.plist */, 172 | ); 173 | path = KIZBehaviorDemoUITests; 174 | sourceTree = ""; 175 | }; 176 | 44F9B1051BE452C7009A0914 /* Classes */ = { 177 | isa = PBXGroup; 178 | children = ( 179 | 44F9B1061BE452C7009A0914 /* KIZBehavior.h */, 180 | 44F9B1071BE452C7009A0914 /* KIZBehavior.m */, 181 | 44F9B1081BE452C7009A0914 /* KIZMultipleProxyBehavior.h */, 182 | 44F9B1091BE452C7009A0914 /* KIZMultipleProxyBehavior.m */, 183 | 44E05D8F1BEE4AF800E9E8D0 /* CharacterLimit */, 184 | 44F9B10A1BE452C7009A0914 /* NavigationBar */, 185 | 44F9B10F1BE452C7009A0914 /* ParallaxHeader */, 186 | ); 187 | path = Classes; 188 | sourceTree = ""; 189 | }; 190 | 44F9B10A1BE452C7009A0914 /* NavigationBar */ = { 191 | isa = PBXGroup; 192 | children = ( 193 | 44F9B10B1BE452C7009A0914 /* KIZNavBarGradientBehavior.h */, 194 | 44F9B10C1BE452C7009A0914 /* KIZNavBarGradientBehavior.m */, 195 | 44F9B10D1BE452C7009A0914 /* UINavigationBar+KIZExtention.h */, 196 | 44F9B10E1BE452C7009A0914 /* UINavigationBar+KIZExtention.m */, 197 | ); 198 | path = NavigationBar; 199 | sourceTree = ""; 200 | }; 201 | 44F9B10F1BE452C7009A0914 /* ParallaxHeader */ = { 202 | isa = PBXGroup; 203 | children = ( 204 | 44F9B1101BE452C7009A0914 /* KIZParallaxHeaderBehavior.h */, 205 | 44F9B1111BE452C7009A0914 /* KIZParallaxHeaderBehavior.m */, 206 | ); 207 | path = ParallaxHeader; 208 | sourceTree = ""; 209 | }; 210 | /* End PBXGroup section */ 211 | 212 | /* Begin PBXNativeTarget section */ 213 | 44F9B0CE1BE45242009A0914 /* KIZBehaviorDemo */ = { 214 | isa = PBXNativeTarget; 215 | buildConfigurationList = 44F9B0FC1BE45242009A0914 /* Build configuration list for PBXNativeTarget "KIZBehaviorDemo" */; 216 | buildPhases = ( 217 | 44F9B0CB1BE45242009A0914 /* Sources */, 218 | 44F9B0CC1BE45242009A0914 /* Frameworks */, 219 | 44F9B0CD1BE45242009A0914 /* Resources */, 220 | ); 221 | buildRules = ( 222 | ); 223 | dependencies = ( 224 | ); 225 | name = KIZBehaviorDemo; 226 | productName = KIZBehaviorDemo; 227 | productReference = 44F9B0CF1BE45242009A0914 /* KIZBehaviorDemo.app */; 228 | productType = "com.apple.product-type.application"; 229 | }; 230 | 44F9B0E71BE45242009A0914 /* KIZBehaviorDemoTests */ = { 231 | isa = PBXNativeTarget; 232 | buildConfigurationList = 44F9B0FF1BE45242009A0914 /* Build configuration list for PBXNativeTarget "KIZBehaviorDemoTests" */; 233 | buildPhases = ( 234 | 44F9B0E41BE45242009A0914 /* Sources */, 235 | 44F9B0E51BE45242009A0914 /* Frameworks */, 236 | 44F9B0E61BE45242009A0914 /* Resources */, 237 | ); 238 | buildRules = ( 239 | ); 240 | dependencies = ( 241 | 44F9B0EA1BE45242009A0914 /* PBXTargetDependency */, 242 | ); 243 | name = KIZBehaviorDemoTests; 244 | productName = KIZBehaviorDemoTests; 245 | productReference = 44F9B0E81BE45242009A0914 /* KIZBehaviorDemoTests.xctest */; 246 | productType = "com.apple.product-type.bundle.unit-test"; 247 | }; 248 | 44F9B0F21BE45242009A0914 /* KIZBehaviorDemoUITests */ = { 249 | isa = PBXNativeTarget; 250 | buildConfigurationList = 44F9B1021BE45242009A0914 /* Build configuration list for PBXNativeTarget "KIZBehaviorDemoUITests" */; 251 | buildPhases = ( 252 | 44F9B0EF1BE45242009A0914 /* Sources */, 253 | 44F9B0F01BE45242009A0914 /* Frameworks */, 254 | 44F9B0F11BE45242009A0914 /* Resources */, 255 | ); 256 | buildRules = ( 257 | ); 258 | dependencies = ( 259 | 44F9B0F51BE45242009A0914 /* PBXTargetDependency */, 260 | ); 261 | name = KIZBehaviorDemoUITests; 262 | productName = KIZBehaviorDemoUITests; 263 | productReference = 44F9B0F31BE45242009A0914 /* KIZBehaviorDemoUITests.xctest */; 264 | productType = "com.apple.product-type.bundle.ui-testing"; 265 | }; 266 | /* End PBXNativeTarget section */ 267 | 268 | /* Begin PBXProject section */ 269 | 44F9B0C71BE45242009A0914 /* Project object */ = { 270 | isa = PBXProject; 271 | attributes = { 272 | LastUpgradeCheck = 0700; 273 | ORGANIZATIONNAME = kingizz; 274 | TargetAttributes = { 275 | 44F9B0CE1BE45242009A0914 = { 276 | CreatedOnToolsVersion = 7.0.1; 277 | }; 278 | 44F9B0E71BE45242009A0914 = { 279 | CreatedOnToolsVersion = 7.0.1; 280 | TestTargetID = 44F9B0CE1BE45242009A0914; 281 | }; 282 | 44F9B0F21BE45242009A0914 = { 283 | CreatedOnToolsVersion = 7.0.1; 284 | TestTargetID = 44F9B0CE1BE45242009A0914; 285 | }; 286 | }; 287 | }; 288 | buildConfigurationList = 44F9B0CA1BE45242009A0914 /* Build configuration list for PBXProject "KIZBehaviorDemo" */; 289 | compatibilityVersion = "Xcode 3.2"; 290 | developmentRegion = English; 291 | hasScannedForEncodings = 0; 292 | knownRegions = ( 293 | en, 294 | Base, 295 | ); 296 | mainGroup = 44F9B0C61BE45242009A0914; 297 | productRefGroup = 44F9B0D01BE45242009A0914 /* Products */; 298 | projectDirPath = ""; 299 | projectRoot = ""; 300 | targets = ( 301 | 44F9B0CE1BE45242009A0914 /* KIZBehaviorDemo */, 302 | 44F9B0E71BE45242009A0914 /* KIZBehaviorDemoTests */, 303 | 44F9B0F21BE45242009A0914 /* KIZBehaviorDemoUITests */, 304 | ); 305 | }; 306 | /* End PBXProject section */ 307 | 308 | /* Begin PBXResourcesBuildPhase section */ 309 | 44F9B0CD1BE45242009A0914 /* Resources */ = { 310 | isa = PBXResourcesBuildPhase; 311 | buildActionMask = 2147483647; 312 | files = ( 313 | 44F9B0E21BE45242009A0914 /* LaunchScreen.storyboard in Resources */, 314 | 44F9B0DF1BE45242009A0914 /* Assets.xcassets in Resources */, 315 | 44F9B0DD1BE45242009A0914 /* Main.storyboard in Resources */, 316 | ); 317 | runOnlyForDeploymentPostprocessing = 0; 318 | }; 319 | 44F9B0E61BE45242009A0914 /* Resources */ = { 320 | isa = PBXResourcesBuildPhase; 321 | buildActionMask = 2147483647; 322 | files = ( 323 | ); 324 | runOnlyForDeploymentPostprocessing = 0; 325 | }; 326 | 44F9B0F11BE45242009A0914 /* Resources */ = { 327 | isa = PBXResourcesBuildPhase; 328 | buildActionMask = 2147483647; 329 | files = ( 330 | ); 331 | runOnlyForDeploymentPostprocessing = 0; 332 | }; 333 | /* End PBXResourcesBuildPhase section */ 334 | 335 | /* Begin PBXSourcesBuildPhase section */ 336 | 44F9B0CB1BE45242009A0914 /* Sources */ = { 337 | isa = PBXSourcesBuildPhase; 338 | buildActionMask = 2147483647; 339 | files = ( 340 | 44F9B1141BE452C7009A0914 /* KIZNavBarGradientBehavior.m in Sources */, 341 | 44F9B1151BE452C7009A0914 /* UINavigationBar+KIZExtention.m in Sources */, 342 | 44F9B1161BE452C7009A0914 /* KIZParallaxHeaderBehavior.m in Sources */, 343 | 44F9B0DA1BE45242009A0914 /* ViewController.m in Sources */, 344 | 44F9B1131BE452C7009A0914 /* KIZMultipleProxyBehavior.m in Sources */, 345 | 44F9B0D71BE45242009A0914 /* AppDelegate.m in Sources */, 346 | 44E05D921BEE4B2500E9E8D0 /* KIZCharacterLimitBehavior.m in Sources */, 347 | 44F9B1121BE452C7009A0914 /* KIZBehavior.m in Sources */, 348 | 44F9B0D41BE45242009A0914 /* main.m in Sources */, 349 | 188C0E411DEE8B000011B9B1 /* DemoForCode.m in Sources */, 350 | ); 351 | runOnlyForDeploymentPostprocessing = 0; 352 | }; 353 | 44F9B0E41BE45242009A0914 /* Sources */ = { 354 | isa = PBXSourcesBuildPhase; 355 | buildActionMask = 2147483647; 356 | files = ( 357 | 44F9B0ED1BE45242009A0914 /* KIZBehaviorDemoTests.m in Sources */, 358 | ); 359 | runOnlyForDeploymentPostprocessing = 0; 360 | }; 361 | 44F9B0EF1BE45242009A0914 /* Sources */ = { 362 | isa = PBXSourcesBuildPhase; 363 | buildActionMask = 2147483647; 364 | files = ( 365 | 44F9B0F81BE45242009A0914 /* KIZBehaviorDemoUITests.m in Sources */, 366 | ); 367 | runOnlyForDeploymentPostprocessing = 0; 368 | }; 369 | /* End PBXSourcesBuildPhase section */ 370 | 371 | /* Begin PBXTargetDependency section */ 372 | 44F9B0EA1BE45242009A0914 /* PBXTargetDependency */ = { 373 | isa = PBXTargetDependency; 374 | target = 44F9B0CE1BE45242009A0914 /* KIZBehaviorDemo */; 375 | targetProxy = 44F9B0E91BE45242009A0914 /* PBXContainerItemProxy */; 376 | }; 377 | 44F9B0F51BE45242009A0914 /* PBXTargetDependency */ = { 378 | isa = PBXTargetDependency; 379 | target = 44F9B0CE1BE45242009A0914 /* KIZBehaviorDemo */; 380 | targetProxy = 44F9B0F41BE45242009A0914 /* PBXContainerItemProxy */; 381 | }; 382 | /* End PBXTargetDependency section */ 383 | 384 | /* Begin PBXVariantGroup section */ 385 | 44F9B0DB1BE45242009A0914 /* Main.storyboard */ = { 386 | isa = PBXVariantGroup; 387 | children = ( 388 | 44F9B0DC1BE45242009A0914 /* Base */, 389 | ); 390 | name = Main.storyboard; 391 | sourceTree = ""; 392 | }; 393 | 44F9B0E01BE45242009A0914 /* LaunchScreen.storyboard */ = { 394 | isa = PBXVariantGroup; 395 | children = ( 396 | 44F9B0E11BE45242009A0914 /* Base */, 397 | ); 398 | name = LaunchScreen.storyboard; 399 | sourceTree = ""; 400 | }; 401 | /* End PBXVariantGroup section */ 402 | 403 | /* Begin XCBuildConfiguration section */ 404 | 44F9B0FA1BE45242009A0914 /* Debug */ = { 405 | isa = XCBuildConfiguration; 406 | buildSettings = { 407 | ALWAYS_SEARCH_USER_PATHS = NO; 408 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 409 | CLANG_CXX_LIBRARY = "libc++"; 410 | CLANG_ENABLE_MODULES = YES; 411 | CLANG_ENABLE_OBJC_ARC = YES; 412 | CLANG_WARN_BOOL_CONVERSION = YES; 413 | CLANG_WARN_CONSTANT_CONVERSION = YES; 414 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 415 | CLANG_WARN_EMPTY_BODY = YES; 416 | CLANG_WARN_ENUM_CONVERSION = YES; 417 | CLANG_WARN_INT_CONVERSION = YES; 418 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 419 | CLANG_WARN_UNREACHABLE_CODE = YES; 420 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 421 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 422 | COPY_PHASE_STRIP = NO; 423 | DEBUG_INFORMATION_FORMAT = dwarf; 424 | ENABLE_STRICT_OBJC_MSGSEND = YES; 425 | ENABLE_TESTABILITY = YES; 426 | GCC_C_LANGUAGE_STANDARD = gnu99; 427 | GCC_DYNAMIC_NO_PIC = NO; 428 | GCC_NO_COMMON_BLOCKS = YES; 429 | GCC_OPTIMIZATION_LEVEL = 0; 430 | GCC_PREPROCESSOR_DEFINITIONS = ( 431 | "DEBUG=1", 432 | "$(inherited)", 433 | ); 434 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 435 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 436 | GCC_WARN_UNDECLARED_SELECTOR = YES; 437 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 438 | GCC_WARN_UNUSED_FUNCTION = YES; 439 | GCC_WARN_UNUSED_VARIABLE = YES; 440 | IPHONEOS_DEPLOYMENT_TARGET = 9.0; 441 | MTL_ENABLE_DEBUG_INFO = YES; 442 | ONLY_ACTIVE_ARCH = YES; 443 | SDKROOT = iphoneos; 444 | }; 445 | name = Debug; 446 | }; 447 | 44F9B0FB1BE45242009A0914 /* Release */ = { 448 | isa = XCBuildConfiguration; 449 | buildSettings = { 450 | ALWAYS_SEARCH_USER_PATHS = NO; 451 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 452 | CLANG_CXX_LIBRARY = "libc++"; 453 | CLANG_ENABLE_MODULES = YES; 454 | CLANG_ENABLE_OBJC_ARC = YES; 455 | CLANG_WARN_BOOL_CONVERSION = YES; 456 | CLANG_WARN_CONSTANT_CONVERSION = YES; 457 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 458 | CLANG_WARN_EMPTY_BODY = YES; 459 | CLANG_WARN_ENUM_CONVERSION = YES; 460 | CLANG_WARN_INT_CONVERSION = YES; 461 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 462 | CLANG_WARN_UNREACHABLE_CODE = YES; 463 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 464 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 465 | COPY_PHASE_STRIP = NO; 466 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 467 | ENABLE_NS_ASSERTIONS = NO; 468 | ENABLE_STRICT_OBJC_MSGSEND = YES; 469 | GCC_C_LANGUAGE_STANDARD = gnu99; 470 | GCC_NO_COMMON_BLOCKS = YES; 471 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 472 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 473 | GCC_WARN_UNDECLARED_SELECTOR = YES; 474 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 475 | GCC_WARN_UNUSED_FUNCTION = YES; 476 | GCC_WARN_UNUSED_VARIABLE = YES; 477 | IPHONEOS_DEPLOYMENT_TARGET = 9.0; 478 | MTL_ENABLE_DEBUG_INFO = NO; 479 | SDKROOT = iphoneos; 480 | VALIDATE_PRODUCT = YES; 481 | }; 482 | name = Release; 483 | }; 484 | 44F9B0FD1BE45242009A0914 /* Debug */ = { 485 | isa = XCBuildConfiguration; 486 | buildSettings = { 487 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 488 | INFOPLIST_FILE = KIZBehaviorDemo/Info.plist; 489 | IPHONEOS_DEPLOYMENT_TARGET = 7.0; 490 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 491 | PRODUCT_BUNDLE_IDENTIFIER = com.kingizz.KIZBehaviorDemo; 492 | PRODUCT_NAME = "$(TARGET_NAME)"; 493 | }; 494 | name = Debug; 495 | }; 496 | 44F9B0FE1BE45242009A0914 /* Release */ = { 497 | isa = XCBuildConfiguration; 498 | buildSettings = { 499 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 500 | INFOPLIST_FILE = KIZBehaviorDemo/Info.plist; 501 | IPHONEOS_DEPLOYMENT_TARGET = 7.0; 502 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 503 | PRODUCT_BUNDLE_IDENTIFIER = com.kingizz.KIZBehaviorDemo; 504 | PRODUCT_NAME = "$(TARGET_NAME)"; 505 | }; 506 | name = Release; 507 | }; 508 | 44F9B1001BE45242009A0914 /* Debug */ = { 509 | isa = XCBuildConfiguration; 510 | buildSettings = { 511 | BUNDLE_LOADER = "$(TEST_HOST)"; 512 | INFOPLIST_FILE = KIZBehaviorDemoTests/Info.plist; 513 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 514 | PRODUCT_BUNDLE_IDENTIFIER = com.kingizz.KIZBehaviorDemoTests; 515 | PRODUCT_NAME = "$(TARGET_NAME)"; 516 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/KIZBehaviorDemo.app/KIZBehaviorDemo"; 517 | }; 518 | name = Debug; 519 | }; 520 | 44F9B1011BE45242009A0914 /* Release */ = { 521 | isa = XCBuildConfiguration; 522 | buildSettings = { 523 | BUNDLE_LOADER = "$(TEST_HOST)"; 524 | INFOPLIST_FILE = KIZBehaviorDemoTests/Info.plist; 525 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 526 | PRODUCT_BUNDLE_IDENTIFIER = com.kingizz.KIZBehaviorDemoTests; 527 | PRODUCT_NAME = "$(TARGET_NAME)"; 528 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/KIZBehaviorDemo.app/KIZBehaviorDemo"; 529 | }; 530 | name = Release; 531 | }; 532 | 44F9B1031BE45242009A0914 /* Debug */ = { 533 | isa = XCBuildConfiguration; 534 | buildSettings = { 535 | INFOPLIST_FILE = KIZBehaviorDemoUITests/Info.plist; 536 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 537 | PRODUCT_BUNDLE_IDENTIFIER = com.kingizz.KIZBehaviorDemoUITests; 538 | PRODUCT_NAME = "$(TARGET_NAME)"; 539 | TEST_TARGET_NAME = KIZBehaviorDemo; 540 | USES_XCTRUNNER = YES; 541 | }; 542 | name = Debug; 543 | }; 544 | 44F9B1041BE45242009A0914 /* Release */ = { 545 | isa = XCBuildConfiguration; 546 | buildSettings = { 547 | INFOPLIST_FILE = KIZBehaviorDemoUITests/Info.plist; 548 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 549 | PRODUCT_BUNDLE_IDENTIFIER = com.kingizz.KIZBehaviorDemoUITests; 550 | PRODUCT_NAME = "$(TARGET_NAME)"; 551 | TEST_TARGET_NAME = KIZBehaviorDemo; 552 | USES_XCTRUNNER = YES; 553 | }; 554 | name = Release; 555 | }; 556 | /* End XCBuildConfiguration section */ 557 | 558 | /* Begin XCConfigurationList section */ 559 | 44F9B0CA1BE45242009A0914 /* Build configuration list for PBXProject "KIZBehaviorDemo" */ = { 560 | isa = XCConfigurationList; 561 | buildConfigurations = ( 562 | 44F9B0FA1BE45242009A0914 /* Debug */, 563 | 44F9B0FB1BE45242009A0914 /* Release */, 564 | ); 565 | defaultConfigurationIsVisible = 0; 566 | defaultConfigurationName = Release; 567 | }; 568 | 44F9B0FC1BE45242009A0914 /* Build configuration list for PBXNativeTarget "KIZBehaviorDemo" */ = { 569 | isa = XCConfigurationList; 570 | buildConfigurations = ( 571 | 44F9B0FD1BE45242009A0914 /* Debug */, 572 | 44F9B0FE1BE45242009A0914 /* Release */, 573 | ); 574 | defaultConfigurationIsVisible = 0; 575 | defaultConfigurationName = Release; 576 | }; 577 | 44F9B0FF1BE45242009A0914 /* Build configuration list for PBXNativeTarget "KIZBehaviorDemoTests" */ = { 578 | isa = XCConfigurationList; 579 | buildConfigurations = ( 580 | 44F9B1001BE45242009A0914 /* Debug */, 581 | 44F9B1011BE45242009A0914 /* Release */, 582 | ); 583 | defaultConfigurationIsVisible = 0; 584 | defaultConfigurationName = Release; 585 | }; 586 | 44F9B1021BE45242009A0914 /* Build configuration list for PBXNativeTarget "KIZBehaviorDemoUITests" */ = { 587 | isa = XCConfigurationList; 588 | buildConfigurations = ( 589 | 44F9B1031BE45242009A0914 /* Debug */, 590 | 44F9B1041BE45242009A0914 /* Release */, 591 | ); 592 | defaultConfigurationIsVisible = 0; 593 | defaultConfigurationName = Release; 594 | }; 595 | /* End XCConfigurationList section */ 596 | }; 597 | rootObject = 44F9B0C71BE45242009A0914 /* Project object */; 598 | } 599 | -------------------------------------------------------------------------------- /KIZBehaviorDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /KIZBehaviorDemo/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // KIZBehaviorDemo 4 | // 5 | // Created by kingizz on 15/10/31. 6 | // Copyright © 2015年 kingizz. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | 16 | @end 17 | 18 | -------------------------------------------------------------------------------- /KIZBehaviorDemo/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // KIZBehaviorDemo 4 | // 5 | // Created by kingizz on 15/10/31. 6 | // Copyright © 2015年 kingizz. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | 11 | @interface AppDelegate () 12 | 13 | @end 14 | 15 | @implementation AppDelegate 16 | 17 | 18 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 19 | // Override point for customization after application launch. 20 | return YES; 21 | } 22 | 23 | - (void)applicationWillResignActive:(UIApplication *)application { 24 | // 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. 25 | // 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. 26 | } 27 | 28 | - (void)applicationDidEnterBackground:(UIApplication *)application { 29 | // 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. 30 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 31 | } 32 | 33 | - (void)applicationWillEnterForeground:(UIApplication *)application { 34 | // 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. 35 | } 36 | 37 | - (void)applicationDidBecomeActive:(UIApplication *)application { 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 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 43 | } 44 | 45 | @end 46 | -------------------------------------------------------------------------------- /KIZBehaviorDemo/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 | "info" : { 35 | "version" : 1, 36 | "author" : "xcode" 37 | } 38 | } -------------------------------------------------------------------------------- /KIZBehaviorDemo/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /KIZBehaviorDemo/Assets.xcassets/hashiqi.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "dog.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /KIZBehaviorDemo/Assets.xcassets/hashiqi.imageset/dog.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zziking/KIZBehavior/e805e8f8f88162dcada30eee3270939e379bad85/KIZBehaviorDemo/Assets.xcassets/hashiqi.imageset/dog.png -------------------------------------------------------------------------------- /KIZBehaviorDemo/Assets.xcassets/share.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "share_pink_hollow@2x.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "filename" : "share_pink_hollow@3x.png", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /KIZBehaviorDemo/Assets.xcassets/share.imageset/share_pink_hollow@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zziking/KIZBehavior/e805e8f8f88162dcada30eee3270939e379bad85/KIZBehaviorDemo/Assets.xcassets/share.imageset/share_pink_hollow@2x.png -------------------------------------------------------------------------------- /KIZBehaviorDemo/Assets.xcassets/share.imageset/share_pink_hollow@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zziking/KIZBehavior/e805e8f8f88162dcada30eee3270939e379bad85/KIZBehaviorDemo/Assets.xcassets/share.imageset/share_pink_hollow@3x.png -------------------------------------------------------------------------------- /KIZBehaviorDemo/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 | -------------------------------------------------------------------------------- /KIZBehaviorDemo/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 | 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 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | 269 | 270 | 271 | 272 | 273 | 274 | 275 | 276 | 277 | 278 | 279 | 280 | 281 | 282 | 283 | 284 | 285 | 286 | 287 | 288 | 289 | 290 | 297 | 298 | 299 | 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308 | 309 | 310 | 311 | 312 | 313 | 314 | 315 | 316 | 317 | 318 | 319 | 320 | 321 | 322 | 323 | 324 | 325 | 326 | 327 | 328 | 329 | 330 | 331 | 332 | 333 | 334 | 335 | 336 | 337 | 338 | 339 | 340 | 341 | 342 | 343 | 344 | 345 | 346 | 347 | 348 | 349 | 350 | 351 | 352 | 353 | 354 | 355 | 356 | 357 | 358 | 359 | 360 | 361 | 362 | 363 | 364 | 365 | 366 | 367 | 368 | 369 | 370 | 371 | 372 | 373 | 374 | 375 | 376 | 377 | 378 | 379 | 380 | 381 | 382 | 383 | 384 | 385 | 386 | 387 | 388 | 389 | 390 | 391 | 392 | 393 | 394 | 395 | 396 | 403 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 419 | 420 | 421 | 422 | 423 | 424 | 425 | 426 | 427 | 428 | 429 | 430 | 431 | 432 | 433 | 434 | 435 | 436 | 437 | 438 | 439 | 440 | 441 | 442 | 443 | 444 | 445 | 446 | 447 | 448 | 449 | 450 | 451 | 452 | 453 | 454 | 455 | 456 | 457 | 458 | 459 | 460 | 466 | 467 | 468 | 469 | 470 | 471 | 472 | 473 | 474 | 475 | 476 | 477 | 478 | 479 | 480 | 481 | 482 | 483 | 484 | 485 | 486 | 487 | 488 | 489 | 490 | 491 | 492 | 493 | 494 | 495 | 496 | 497 | 498 | 499 | 500 | 501 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 509 | 510 | 511 | 512 | 513 | 514 | 515 | 516 | 517 | 518 | 519 | 520 | 521 | 522 | 523 | 524 | 525 | 526 | 527 | 528 | 529 | 536 | 537 | 538 | 539 | 540 | 541 | 542 | 543 | 544 | 545 | 546 | 547 | 548 | 549 | 550 | 551 | 552 | 553 | 554 | 555 | 556 | 557 | 558 | 559 | 560 | 561 | 562 | 563 | 564 | 565 | 566 | 567 | 568 | 569 | 570 | 571 | 572 | 573 | 574 | 575 | 576 | 577 | 578 | 579 | 580 | 581 | 582 | 583 | 584 | 585 | 586 | 587 | 588 | 589 | 590 | 591 | 592 | 593 | 594 | 595 | 596 | 597 | 598 | 599 | 600 | 601 | 602 | 603 | 604 | 605 | 606 | 607 | 608 | 609 | 610 | -------------------------------------------------------------------------------- /KIZBehaviorDemo/Classes/CharacterLimit/KIZCharacterLimitBehavior.h: -------------------------------------------------------------------------------- 1 | // 2 | // KIZCharacterLimitBehavior.h 3 | // KIZBehaviorDemo https://github.com/zziking/KIZBehavior 4 | // 5 | // Created by kingizz on 15/11/7. 6 | // Copyright © 2015年 kingizz. All rights reserved. 7 | // 8 | 9 | #import "KIZBehavior.h" 10 | 11 | @interface KIZCharacterLimitBehavior : KIZBehavior 12 | 13 | @property (nonatomic, weak ) IBOutlet UITextView *textView; 14 | @property (nonatomic, weak ) IBOutlet UILabel *countLabel; 15 | @property (nonatomic, assign) IBInspectable NSUInteger maxCount; 16 | @property (nonatomic, assign) IBInspectable BOOL hideKeyboardOnReturn; 17 | 18 | @end 19 | -------------------------------------------------------------------------------- /KIZBehaviorDemo/Classes/CharacterLimit/KIZCharacterLimitBehavior.m: -------------------------------------------------------------------------------- 1 | // 2 | // KIZCharacterLimitBehavior.m 3 | // KIZBehaviorDemo 4 | // 5 | // Created by kingizz on 15/11/7. 6 | // Copyright © 2015年 kingizz. All rights reserved. 7 | // 8 | 9 | #import "KIZCharacterLimitBehavior.h" 10 | 11 | @implementation KIZCharacterLimitBehavior 12 | 13 | - (void)updateCharacterLimit:(NSString *)text 14 | { 15 | self.countLabel.text = [NSString stringWithFormat:@"%@/%@", @(text.length), @(_maxCount)]; 16 | } 17 | 18 | - (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text 19 | { 20 | if (self.hideKeyboardOnReturn && [text rangeOfCharacterFromSet:[NSCharacterSet newlineCharacterSet]].location != NSNotFound) { 21 | [textView resignFirstResponder]; 22 | return NO; 23 | } 24 | 25 | 26 | UITextRange *selectedRange = [textView markedTextRange]; 27 | if (selectedRange) { 28 | return YES; 29 | } 30 | 31 | 32 | NSString *modifiedText = [textView.text stringByReplacingCharactersInRange:range withString:text]; 33 | const BOOL willModifyText = modifiedText.length <= self.maxCount; 34 | if (willModifyText) { 35 | [self updateCharacterLimit:modifiedText]; 36 | } 37 | return willModifyText; 38 | } 39 | 40 | - (void)textViewDidChange:(UITextView *)textView 41 | { 42 | 43 | UITextRange *selectedRange = [textView markedTextRange]; 44 | if (selectedRange) { 45 | return; 46 | } 47 | 48 | if (textView.text.length > self.maxCount) 49 | { 50 | NSString *text = textView.text; 51 | BOOL asc = [text canBeConvertedToEncoding:NSASCIIStringEncoding]; 52 | if (asc) { 53 | self.textView.text = [text substringToIndex:self.maxCount]; 54 | 55 | }else{ 56 | //对于emoji表情,会占用两个长度 57 | __block NSInteger idx = 0; 58 | [text enumerateSubstringsInRange:NSMakeRange(0, [text length]) 59 | options:NSStringEnumerationByComposedCharacterSequences 60 | usingBlock: ^(NSString* substring, NSRange substringRange, NSRange enclosingRange, BOOL* stop) { 61 | 62 | if (idx + substring.length > self.maxCount) { 63 | *stop = YES; 64 | return ; 65 | } 66 | 67 | idx += substring.length; 68 | }]; 69 | 70 | textView.text = [textView.text substringToIndex:idx]; 71 | } 72 | 73 | } 74 | 75 | [self updateCharacterLimit:textView.text]; 76 | } 77 | 78 | #pragma mark - Getters & Setters 79 | - (void)setTextView:(UITextView *)textView 80 | { 81 | _textView = textView; 82 | [self updateCharacterLimit:self.textView.text]; 83 | } 84 | 85 | - (void)setCounterLabel:(UILabel *)counterLabel 86 | { 87 | _countLabel = counterLabel; 88 | [self updateCharacterLimit:self.textView.text]; 89 | } 90 | 91 | @end 92 | -------------------------------------------------------------------------------- /KIZBehaviorDemo/Classes/KIZBehavior.h: -------------------------------------------------------------------------------- 1 | // 2 | // KIZBehavior.h 3 | // KIZParallaTableDemo https://github.com/zziking/KIZBehavior 4 | // 5 | // Created by kingizz on 15/8/17. 6 | // Copyright (c) 2015年 kingizz. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface KIZBehavior : NSObject 12 | 13 | @property (nonatomic, weak) IBOutlet id owner; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /KIZBehaviorDemo/Classes/KIZBehavior.m: -------------------------------------------------------------------------------- 1 | // 2 | // KIZBehavior.m 3 | // KIZParallaTableDemo 4 | // 5 | // Created by kingizz on 15/8/17. 6 | // Copyright (c) 2015年 kingizz. All rights reserved. 7 | // 8 | 9 | #import "KIZBehavior.h" 10 | 11 | @implementation KIZBehavior 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /KIZBehaviorDemo/Classes/KIZMultipleProxyBehavior.h: -------------------------------------------------------------------------------- 1 | // 2 | // KIZMultipleProxyBehavior.h 3 | // KIZParallaTableDemo https://github.com/zziking/KIZBehavior 4 | // 5 | // Created by kingizz on 15/8/17. 6 | // Copyright (c) 2015年 kingizz. All rights reserved. 7 | // 8 | 9 | #import "KIZBehavior.h" 10 | 11 | @interface KIZMultipleProxyBehavior : KIZBehavior 12 | 13 | @property (nonatomic, strong) IBOutletCollection(id) NSArray* delegateTargets; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /KIZBehaviorDemo/Classes/KIZMultipleProxyBehavior.m: -------------------------------------------------------------------------------- 1 | // 2 | // KIZMultipleProxyBehavior.m 3 | // KIZParallaTableDemo 4 | // 5 | // Created by kingizz on 15/8/17. 6 | // Copyright (c) 2015年 kingizz. All rights reserved. 7 | // 8 | 9 | #import "KIZMultipleProxyBehavior.h" 10 | 11 | @interface KIZMultipleProxyBehavior () 12 | 13 | @property (nonatomic, strong) NSPointerArray *weakRefTargets; 14 | 15 | @end 16 | 17 | 18 | @implementation KIZMultipleProxyBehavior 19 | 20 | - (void)setDelegateTargets:(NSArray *)delegateTargets{ 21 | self.weakRefTargets = [NSPointerArray weakObjectsPointerArray]; 22 | for (id delegate in delegateTargets) { 23 | [self.weakRefTargets addPointer:(__bridge void *)delegate]; 24 | } 25 | } 26 | 27 | - (BOOL)respondsToSelector:(SEL)aSelector{ 28 | if ([super respondsToSelector:aSelector]) { 29 | return YES; 30 | } 31 | for (id target in self.weakRefTargets) { 32 | if ([target respondsToSelector:aSelector]) { 33 | return YES; 34 | } 35 | } 36 | 37 | return NO; 38 | } 39 | 40 | - (NSMethodSignature *)methodSignatureForSelector:(SEL)aSelector{ 41 | NSMethodSignature *sig = [super methodSignatureForSelector:aSelector]; 42 | if (!sig) { 43 | for (id target in self.weakRefTargets) { 44 | if ((sig = [target methodSignatureForSelector:aSelector])) { 45 | break; 46 | } 47 | } 48 | } 49 | 50 | return sig; 51 | } 52 | 53 | //转发方法调用给所有delegate 54 | - (void)forwardInvocation:(NSInvocation *)anInvocation{ 55 | for (id target in self.weakRefTargets) { 56 | if ([target respondsToSelector:anInvocation.selector]) { 57 | [anInvocation invokeWithTarget:target]; 58 | } 59 | } 60 | } 61 | 62 | @end 63 | -------------------------------------------------------------------------------- /KIZBehaviorDemo/Classes/NavigationBar/KIZNavBarGradientBehavior.h: -------------------------------------------------------------------------------- 1 | // 2 | // KIZNavBarGradientBehavior.h 3 | // KIZParallaTableDemo https://github.com/zziking/KIZBehavior 4 | // 5 | // Created by kingizz on 15/10/3. 6 | // Copyright © 2015年 kingizz. All rights reserved. 7 | // 8 | 9 | #import "KIZBehavior.h" 10 | 11 | @interface KIZNavBarGradientBehavior : KIZBehavior 12 | 13 | /** 状态栏是否颜色是否动态改变,默认为YES,需要在info.plist中设置 View controller-based status bar appearance 为 NO才有效果 */ 14 | @property (nonatomic, assign) IBInspectable BOOL statusBarStyleChange; 15 | 16 | /** 导航栏tintColor变化的临界值默认为200 */ 17 | @property (nonatomic, assign) IBInspectable CGFloat criticalOffset; 18 | 19 | /** 导航栏渐变时的背景颜色,默认为navigationbar.barTintColor */ 20 | @property (nonatomic, strong) IBInspectable UIColor *barBackColor; 21 | 22 | 23 | - (void)onViewWillAppear; 24 | 25 | - (void)onViewWillDisAppear; 26 | 27 | @end 28 | -------------------------------------------------------------------------------- /KIZBehaviorDemo/Classes/NavigationBar/KIZNavBarGradientBehavior.m: -------------------------------------------------------------------------------- 1 | // 2 | // KIZNavBarGradientBehavior.m 3 | // KIZParallaTableDemo 4 | // 5 | // Created by kingizz on 15/10/3. 6 | // Copyright © 2015年 kingizz. All rights reserved. 7 | // 8 | 9 | #import "KIZNavBarGradientBehavior.h" 10 | #import "UINavigationBar+KIZExtention.h" 11 | 12 | 13 | @implementation KIZNavBarGradientBehavior{ 14 | UIColor *_navBarOriginalTintColor; //导航栏初始时的tintColor 15 | UIColor *_navBarCurrentTintColor; //动态变化时导航栏的tintColor 16 | 17 | UIImage *_originalShadowImage; //导航栏的shadowImage 18 | UIImage *_clearShadowImage; 19 | UIImage *_curShadowImage; //当前的shadowImage 20 | 21 | CGFloat _navBarCurBgAlpha; //导航栏当前的透明度 22 | 23 | NSDictionary *_navBarOriginTitleAttribute; //导航栏初始时的titleTextAttribute 24 | NSMutableDictionary *_navBarCurTitleAttribute; //导航栏当前动态变化的titleTextAttribute 25 | 26 | UIStatusBarStyle _statusBarStyle; 27 | 28 | BOOL _didScrolled; //是否已经滚动过 29 | BOOL _navBarDidReset; //是否恢复了导航栏的状态 30 | } 31 | 32 | - (instancetype)init{ 33 | self = [super init]; 34 | if (self) { 35 | self.criticalOffset = 200; 36 | self.statusBarStyleChange = YES; 37 | } 38 | return self; 39 | } 40 | 41 | - (void)scrollViewDidScroll:(UIScrollView *)scrollView{ 42 | UINavigationBar *navBar = [self navigationBar]; 43 | 44 | CGFloat offsetY = scrollView.contentOffset.y; 45 | 46 | //动态变化背景色 47 | _navBarCurBgAlpha = offsetY > 0 ? scrollView.contentOffset.y / self.criticalOffset : 0; 48 | // [navBar kiz_setBackgroundAlpha:_navBarCurBgAlpha]; 49 | [navBar kiz_setBackgroundColor:[self.barBackColor colorWithAlphaComponent:_navBarCurBgAlpha]]; 50 | 51 | //导航栏不透明时,显示原本的shadowImage 52 | if (_navBarCurBgAlpha > 1) { 53 | navBar.shadowImage = _originalShadowImage; 54 | 55 | }else{ 56 | navBar.shadowImage = _clearShadowImage; 57 | 58 | } 59 | _curShadowImage = navBar.shadowImage; 60 | 61 | if (self.statusBarStyleChange && !_navBarDidReset) { 62 | if (_navBarCurBgAlpha > 0.35) { 63 | [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault]; 64 | 65 | }else { 66 | [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent]; 67 | } 68 | } 69 | 70 | 71 | if (!_navBarOriginalTintColor) { 72 | _navBarOriginalTintColor = navBar.tintColor; 73 | } 74 | 75 | _didScrolled = YES; 76 | 77 | //动态变化tintColor 78 | if (offsetY >= 0) { 79 | 80 | UIColor *tintColor = nil; 81 | UIColor *titleColor = nil; 82 | CGFloat alpha = 1; 83 | 84 | CGFloat offset = self.criticalOffset / 2.0; 85 | if (offsetY < offset) { 86 | alpha = 1 - offsetY / offset; 87 | tintColor = [UIColor colorWithWhite:1 alpha:alpha]; 88 | titleColor = tintColor; 89 | 90 | }else{ 91 | alpha = offsetY / offset - 1; 92 | tintColor = [_navBarOriginalTintColor colorWithAlphaComponent:alpha]; 93 | titleColor = tintColor; 94 | 95 | UIColor *originTitleColor = _navBarOriginTitleAttribute[NSForegroundColorAttributeName]; 96 | if (originTitleColor) { 97 | titleColor = [originTitleColor colorWithAlphaComponent:alpha]; 98 | } 99 | 100 | } 101 | 102 | navBar.tintColor = tintColor; 103 | _navBarCurrentTintColor = tintColor; 104 | 105 | _navBarCurTitleAttribute[NSForegroundColorAttributeName] = titleColor; 106 | navBar.titleTextAttributes = _navBarCurTitleAttribute; 107 | 108 | } 109 | 110 | } 111 | 112 | 113 | #pragma mark- public 114 | - (void)onViewWillAppear{ 115 | [self initializeOrRecover]; 116 | } 117 | 118 | - (void)onViewWillDisAppear{ 119 | [self reset]; 120 | } 121 | 122 | #pragma mark- Navgationbar Appearance 123 | /** 124 | * 存储导航栏初始时的状态 125 | * 126 | * @param navBar 127 | */ 128 | - (void)storeNaviBarAppearance:(UINavigationBar *)navBar{ 129 | _navBarOriginalTintColor = navBar.tintColor; 130 | _navBarOriginTitleAttribute = navBar.titleTextAttributes; 131 | _statusBarStyle = [UIApplication sharedApplication].statusBarStyle; 132 | _originalShadowImage = navBar.shadowImage; 133 | 134 | } 135 | 136 | /** 137 | * 恢复导航栏的状态到初始时的状态 138 | * 139 | * @param navBar 140 | */ 141 | - (void)reStoreNaviBarAppearance:(UINavigationBar *)navBar{ 142 | navBar.tintColor = _navBarOriginalTintColor; 143 | navBar.titleTextAttributes = _navBarOriginTitleAttribute; 144 | [navBar kiz_reset]; 145 | [[UIApplication sharedApplication] setStatusBarStyle:_statusBarStyle]; 146 | 147 | } 148 | 149 | #pragma mark- 150 | /** 151 | * 初始化状态 152 | */ 153 | - (void)initialize{ 154 | UINavigationBar *navBar = [self navigationBar]; 155 | _navBarDidReset = NO; 156 | 157 | [self storeNaviBarAppearance:navBar]; 158 | 159 | [navBar kiz_setBackgroundAlpha:0]; 160 | _clearShadowImage = [UIImage new]; 161 | navBar.shadowImage = _clearShadowImage; 162 | 163 | 164 | UIColor *whiteColor = [UIColor whiteColor]; 165 | navBar.tintColor = whiteColor; 166 | 167 | _navBarCurTitleAttribute = [_navBarOriginTitleAttribute mutableCopy]; 168 | if (!_navBarCurTitleAttribute) { 169 | _navBarCurTitleAttribute = [NSMutableDictionary dictionary]; 170 | } 171 | _navBarCurTitleAttribute[NSForegroundColorAttributeName] = whiteColor; 172 | navBar.titleTextAttributes = _navBarCurTitleAttribute; 173 | 174 | [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent]; 175 | } 176 | 177 | /** 178 | * 恢复状态,恢复到重置状态之前时的状态 179 | */ 180 | - (void)recover{ 181 | UINavigationBar *navBar = [self navigationBar]; 182 | 183 | if (_navBarCurrentTintColor) { 184 | navBar.tintColor = _navBarCurrentTintColor; 185 | } 186 | 187 | navBar.titleTextAttributes = _navBarCurTitleAttribute; 188 | 189 | // [navBar kiz_setBackgroundAlpha:_navBarCurBgAlpha]; 190 | [navBar kiz_setBackgroundColor:[self.barBackColor colorWithAlphaComponent:_navBarCurBgAlpha]]; 191 | 192 | navBar.shadowImage = _curShadowImage; 193 | } 194 | 195 | /** 196 | * 根据当前状态自动调用initialize或者recover方法 197 | */ 198 | - (void)initializeOrRecover{ 199 | if (_didScrolled) { 200 | [self recover]; 201 | 202 | }else{ 203 | [self initialize]; 204 | } 205 | } 206 | 207 | /** 208 | * 重置状态,回到初始化时的状态,在Controller的viewWillDisAppear中调用 209 | */ 210 | - (void)reset{ 211 | _navBarDidReset = YES; 212 | 213 | UINavigationBar *navBar = [self navigationBar]; 214 | [self reStoreNaviBarAppearance:navBar]; 215 | } 216 | 217 | #pragma mark- 218 | - (UINavigationBar *)navigationBar{ 219 | return ((UIViewController *)self.owner).navigationController.navigationBar; 220 | } 221 | 222 | - (UIColor *)barBackColor{ 223 | if (!_barBackColor) { 224 | _barBackColor = [self navigationBar].barTintColor; 225 | } 226 | return _barBackColor; 227 | } 228 | @end 229 | -------------------------------------------------------------------------------- /KIZBehaviorDemo/Classes/NavigationBar/UINavigationBar+KIZExtention.h: -------------------------------------------------------------------------------- 1 | // 2 | // UINavigationBar+KIZExtention.h 3 | // KIZParallaTableDemo https://github.com/zziking/KIZBehavior 4 | // 5 | // Created by kingizz on 15/10/3. 6 | // Copyright © 2015年 kingizz. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface UINavigationBar (KIZExtention) 12 | 13 | /** 14 | * 设置导航栏透明度 15 | * 16 | * @param alpha 17 | */ 18 | - (void)kiz_setBackgroundAlpha:(CGFloat)alpha; 19 | 20 | /** 21 | * 设置导航栏背景颜色 22 | * 23 | * @param color 24 | */ 25 | - (void)kiz_setBackgroundColor:(UIColor *)color; 26 | 27 | /** 28 | * 重置导航栏的状态,恢复到初始时的状态 29 | */ 30 | - (void)kiz_reset; 31 | 32 | @end 33 | -------------------------------------------------------------------------------- /KIZBehaviorDemo/Classes/NavigationBar/UINavigationBar+KIZExtention.m: -------------------------------------------------------------------------------- 1 | // 2 | // UINavigationBar+KIZExtention.m 3 | // KIZParallaTableDemo 4 | // 5 | // Created by kingizz on 15/10/3. 6 | // Copyright © 2015年 kingizz. All rights reserved. 7 | // 8 | 9 | #import "UINavigationBar+KIZExtention.h" 10 | #import 11 | 12 | @interface UINavigationBar () 13 | 14 | @property (nonatomic, assign) BOOL kizOriginIsTranslucent; 15 | @property (nonatomic, strong) UIImage *kizOriginBackgroundImage; 16 | @property (nonatomic, strong) UIImage *kizOriginShadowImage; 17 | @property (nonatomic, strong) UIView *kizBackgroundView; 18 | 19 | @end 20 | 21 | @implementation UINavigationBar (KIZExtention) 22 | 23 | 24 | - (void)kiz_setBackgroundAlpha:(CGFloat)alpha{ 25 | [self kiz_setBackgroundColor:[self.barTintColor colorWithAlphaComponent:alpha]]; 26 | } 27 | 28 | - (void)kiz_setBackgroundColor:(UIColor *)color{ 29 | if (!self.kizBackgroundView) { 30 | self.kizOriginBackgroundImage = [self backgroundImageForBarMetrics:UIBarMetricsDefault]; 31 | self.kizOriginShadowImage = self.shadowImage; 32 | self.kizOriginIsTranslucent = self.translucent; 33 | 34 | [self setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault]; 35 | [self setShadowImage:nil]; 36 | 37 | UIView *bgView = [[UIView alloc] initWithFrame:CGRectMake(0, -20, [UIScreen mainScreen].bounds.size.width, self.bounds.size.height + 20)]; 38 | bgView.userInteractionEnabled = NO; 39 | [self insertSubview:bgView atIndex:0]; 40 | 41 | self.kizBackgroundView = bgView; 42 | self.translucent = YES; 43 | 44 | } 45 | self.kizBackgroundView.backgroundColor = color; 46 | 47 | } 48 | 49 | - (void)kiz_reset{ 50 | [self setBackgroundImage:self.kizOriginBackgroundImage forBarMetrics:UIBarMetricsDefault]; 51 | [self setShadowImage:self.kizOriginShadowImage]; 52 | [self setTranslucent:self.kizOriginIsTranslucent]; 53 | 54 | [self.kizBackgroundView removeFromSuperview]; 55 | self.kizOriginBackgroundImage = nil; 56 | self.kizOriginShadowImage = nil; 57 | self.kizBackgroundView = nil; 58 | } 59 | 60 | #pragma mark- getters & setters 61 | 62 | - (UIImage *)kizOriginBackgroundImage{ 63 | return objc_getAssociatedObject(self, @selector(kizOriginBackgroundImage)); 64 | } 65 | - (void)setKizOriginBackgroundImage:(UIImage *)kizOriginBackgroundImage{ 66 | objc_setAssociatedObject(self, @selector(kizOriginBackgroundImage), kizOriginBackgroundImage, OBJC_ASSOCIATION_RETAIN_NONATOMIC); 67 | } 68 | 69 | - (UIImage *)kizOriginShadowImage{ 70 | return objc_getAssociatedObject(self, @selector(kizOriginShadowImage)); 71 | } 72 | - (void)setKizOriginShadowImage:(UIImage *)kizOriginShadowImage{ 73 | objc_setAssociatedObject(self, @selector(kizOriginShadowImage), kizOriginShadowImage, OBJC_ASSOCIATION_RETAIN_NONATOMIC); 74 | } 75 | 76 | - (UIView *)kizBackgroundView{ 77 | return objc_getAssociatedObject(self, @selector(kizBackgroundView)); 78 | } 79 | - (void)setKizBackgroundView:(UIView *)kizBackgroundView{ 80 | objc_setAssociatedObject(self, @selector(kizBackgroundView), kizBackgroundView, OBJC_ASSOCIATION_RETAIN_NONATOMIC); 81 | } 82 | 83 | 84 | - (BOOL)kizOriginIsTranslucent{ 85 | return [objc_getAssociatedObject(self, @selector(kizOriginIsTranslucent)) boolValue]; 86 | } 87 | - (void)setKizOriginIsTranslucent:(BOOL)kizOriginIsTranslucent{ 88 | objc_setAssociatedObject(self, @selector(kizOriginIsTranslucent), @(kizOriginIsTranslucent), OBJC_ASSOCIATION_RETAIN_NONATOMIC); 89 | } 90 | 91 | @end 92 | -------------------------------------------------------------------------------- /KIZBehaviorDemo/Classes/ParallaxHeader/KIZParallaxHeaderBehavior.h: -------------------------------------------------------------------------------- 1 | // 2 | // KIZParallaxTableBehavior.h 3 | // KIZParallaTableDemo https://github.com/zziking/KIZBehavior 4 | // 5 | // Created by kingizz on 15/8/18. 6 | // Copyright (c) 2015年 kingizz. All rights reserved. 7 | // 8 | 9 | #import "KIZBehavior.h" 10 | 11 | @interface KIZParallaxHeaderBehavior : KIZBehavior 12 | 13 | @property (nonatomic, weak) IBOutlet UIView* targetView; 14 | /** 15 | * 向上滚动时,背景与scrollview offsetY的视差倍率,默认0.6 16 | */ 17 | @property (nonatomic, assign) IBInspectable CGFloat offsetMultiple; 18 | 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /KIZBehaviorDemo/Classes/ParallaxHeader/KIZParallaxHeaderBehavior.m: -------------------------------------------------------------------------------- 1 | // 2 | // KIZParallaxTableBehavior.m 3 | // KIZParallaTableDemo 4 | // 5 | // Created by kingizz on 15/8/18. 6 | // Copyright (c) 2015年 kingizz. All rights reserved. 7 | // 8 | 9 | #import "KIZParallaxHeaderBehavior.h" 10 | 11 | #define defaultOffsetMultiple 0.6 12 | 13 | @interface KIZParallaxHeaderBehavior () 14 | 15 | @property (nonatomic, assign) CGRect targetViewOriginFrame; 16 | 17 | @end 18 | 19 | @implementation KIZParallaxHeaderBehavior{ 20 | BOOL _didInited; 21 | } 22 | 23 | 24 | - (void)scrollViewDidScroll:(UIScrollView *)scrollView{ 25 | 26 | if (!_didInited) { 27 | 28 | _targetViewOriginFrame = self.targetView.frame; 29 | _didInited = YES; 30 | 31 | if (_offsetMultiple > 1 || _offsetMultiple <= 0) { 32 | _offsetMultiple = defaultOffsetMultiple; 33 | } 34 | 35 | } 36 | 37 | CGFloat offsetY = scrollView.contentOffset.y; 38 | 39 | if (offsetY >= 0) { 40 | //向上滚动 41 | CGFloat increment = offsetY * _offsetMultiple; 42 | self.targetView.frame = CGRectMake(_targetViewOriginFrame.origin.x, 43 | _targetViewOriginFrame.origin.y - increment, 44 | _targetViewOriginFrame.size.width, 45 | _targetViewOriginFrame.size.height 46 | ); 47 | 48 | }else{ 49 | //向下滚动 50 | CGFloat heigth = _targetViewOriginFrame.size.height + ABS(offsetY); 51 | CGFloat width = heigth * _targetViewOriginFrame.size.width / _targetViewOriginFrame.size.height; 52 | CGFloat x = _targetViewOriginFrame.origin.x - (width - _targetViewOriginFrame.size.width) / 2.0; 53 | 54 | self.targetView.frame = CGRectMake( x, _targetViewOriginFrame.origin.y, width, heigth ); 55 | 56 | } 57 | 58 | } 59 | 60 | 61 | - (void)setOffsetMultiple:(CGFloat)offsetMultiple{ 62 | if (offsetMultiple > 1 || offsetMultiple <= 0) { 63 | _offsetMultiple = defaultOffsetMultiple; 64 | }else{ 65 | _offsetMultiple = offsetMultiple; 66 | } 67 | } 68 | @end 69 | -------------------------------------------------------------------------------- /KIZBehaviorDemo/DemoForCode.h: -------------------------------------------------------------------------------- 1 | // 2 | // DemoForCode.h 3 | // KIZBehaviorDemo 4 | // 5 | // Created by apple on 16/11/30. 6 | // Copyright © 2016年 kingizz. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface DemoForCode : UIViewController 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /KIZBehaviorDemo/DemoForCode.m: -------------------------------------------------------------------------------- 1 | // 2 | // DemoForCode.m 3 | // KIZBehaviorDemo 4 | // 5 | // Created by apple on 16/11/30. 6 | // Copyright © 2016年 kingizz. All rights reserved. 7 | // 8 | 9 | #import "DemoForCode.h" 10 | #import "KIZNavBarGradientBehavior.h" 11 | #import "KIZParallaxHeaderBehavior.h" 12 | #import "KIZMultipleProxyBehavior.h" 13 | 14 | @interface DemoForCode () 15 | 16 | @property (nonatomic, strong) UITableView *tableView; 17 | @property (nonatomic, strong) KIZParallaxHeaderBehavior *parallaxBehavior; 18 | @property (nonatomic, strong) KIZNavBarGradientBehavior *navBehavior; 19 | @property (nonatomic, strong) KIZMultipleProxyBehavior *behaviors; 20 | 21 | @end 22 | 23 | @implementation DemoForCode 24 | 25 | - (void)viewDidLoad { 26 | [super viewDidLoad]; 27 | 28 | UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"hashiqi"]]; 29 | imageView.frame = CGRectMake(0, 0, self.view.bounds.size.width, 250); 30 | [self.view addSubview:imageView]; 31 | 32 | UIView *tableHeader = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.bounds.size.width, 250)]; 33 | tableHeader.backgroundColor = [UIColor clearColor]; 34 | 35 | //视图放大缩小视差效果 36 | KIZParallaxHeaderBehavior *parallaxBehavior = [[KIZParallaxHeaderBehavior alloc] init]; 37 | parallaxBehavior.targetView = imageView; 38 | self.parallaxBehavior = parallaxBehavior; 39 | 40 | //导航栏渐变效果 41 | KIZNavBarGradientBehavior *navBehavior = [[KIZNavBarGradientBehavior alloc] init]; 42 | // navBehavior.criticalOffset = 400; 43 | navBehavior.owner = self; 44 | self.navBehavior = navBehavior; 45 | 46 | //代理转发的目标,会将事件转发到所有能处理事件的代理对象,因为多重代理对象内部不会强引用数组中的对象,所以数组中的self不会用循环引用,同时,其他behavior需要在此controller中强引用,防止被释放 47 | NSArray *delegates = @[self, parallaxBehavior, navBehavior]; 48 | KIZMultipleProxyBehavior *behaviors = [[KIZMultipleProxyBehavior alloc] init]; 49 | behaviors.delegateTargets = delegates; 50 | self.behaviors = behaviors; 51 | 52 | UITableView *tableView = [[UITableView alloc] initWithFrame:self.view.bounds style:UITableViewStylePlain]; 53 | tableView.dataSource = (id)self.behaviors; 54 | tableView.delegate = (id)self.behaviors; 55 | tableView.tableHeaderView = tableHeader; 56 | tableView.backgroundColor = [UIColor clearColor]; 57 | // [tableView insertSubview:imageView atIndex:0]; 58 | 59 | [self.view addSubview:tableView]; 60 | self.tableView = tableView; 61 | 62 | 63 | } 64 | 65 | - (void)viewWillAppear:(BOOL)animated{ 66 | [super viewWillAppear:animated]; 67 | 68 | [self.navBehavior onViewWillAppear]; 69 | } 70 | 71 | - (void)viewWillDisappear:(BOOL)animated{ 72 | [super viewWillDisappear:animated]; 73 | 74 | [self.navBehavior onViewWillDisAppear]; 75 | } 76 | 77 | - (void)didReceiveMemoryWarning { 78 | [super didReceiveMemoryWarning]; 79 | // Dispose of any resources that can be recreated. 80 | } 81 | 82 | #pragma mark- UITableViewDataSource & UITableViewDelegate 83 | - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{ 84 | return 20; 85 | } 86 | 87 | - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ 88 | UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"]; 89 | if (!cell) { 90 | cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell"]; 91 | } 92 | cell.textLabel.text = [@(indexPath.row) stringValue]; 93 | return cell; 94 | } 95 | 96 | @end 97 | -------------------------------------------------------------------------------- /KIZBehaviorDemo/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 | UIViewControllerBasedStatusBarAppearance 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /KIZBehaviorDemo/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // KIZParallaTableDemo 4 | // 5 | // Created by kingizz on 15/8/17. 6 | // Copyright (c) 2015年 kingizz. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /KIZBehaviorDemo/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // KIZParallaTableDemo 4 | // 5 | // Created by kingizz on 15/8/17. 6 | // Copyright (c) 2015年 kingizz. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | #import "KIZNavBarGradientBehavior.h" 11 | 12 | @interface ViewController () 13 | 14 | @property (strong, nonatomic) IBOutlet KIZNavBarGradientBehavior *navBarBehavior; 15 | @end 16 | 17 | @implementation ViewController 18 | 19 | - (void)viewDidLoad { 20 | [super viewDidLoad]; 21 | 22 | CAGradientLayer *layer = [CAGradientLayer layer]; 23 | layer.frame = CGRectMake(0, 0, self.view.bounds.size.width, 64); 24 | layer.colors = @[(id)[[UIColor blackColor] colorWithAlphaComponent:0.6].CGColor, (id)[UIColor clearColor].CGColor]; 25 | layer.startPoint = CGPointMake(0.5, 0.0); 26 | layer.endPoint = CGPointMake(0.5, 1.0); 27 | 28 | [self.view.layer insertSublayer:layer atIndex:1]; 29 | } 30 | 31 | - (void)viewWillAppear:(BOOL)animated{ 32 | [super viewWillAppear:animated]; 33 | 34 | [self.navBarBehavior onViewWillAppear]; 35 | } 36 | 37 | - (void)viewWillDisappear:(BOOL)animated{ 38 | [super viewWillDisappear:animated]; 39 | 40 | [self.navBarBehavior onViewWillDisAppear]; 41 | } 42 | 43 | - (void)didReceiveMemoryWarning { 44 | [super didReceiveMemoryWarning]; 45 | // Dispose of any resources that can be recreated. 46 | } 47 | 48 | - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{ 49 | return 20; 50 | } 51 | 52 | - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ 53 | UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"]; 54 | if (!cell) { 55 | cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell"]; 56 | } 57 | cell.textLabel.text = [@(indexPath.row) stringValue]; 58 | return cell; 59 | } 60 | 61 | 62 | 63 | @end 64 | -------------------------------------------------------------------------------- /KIZBehaviorDemo/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // KIZBehaviorDemo 4 | // 5 | // Created by kingizz on 15/10/31. 6 | // Copyright © 2015年 kingizz. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /KIZBehaviorDemoTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /KIZBehaviorDemoTests/KIZBehaviorDemoTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // KIZBehaviorDemoTests.m 3 | // KIZBehaviorDemoTests 4 | // 5 | // Created by kingizz on 15/10/31. 6 | // Copyright © 2015年 kingizz. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface KIZBehaviorDemoTests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation KIZBehaviorDemoTests 16 | 17 | - (void)setUp { 18 | [super setUp]; 19 | // Put setup code here. This method is called before the invocation of each test method in the class. 20 | } 21 | 22 | - (void)tearDown { 23 | // Put teardown code here. This method is called after the invocation of each test method in the class. 24 | [super tearDown]; 25 | } 26 | 27 | - (void)testExample { 28 | // This is an example of a functional test case. 29 | // Use XCTAssert and related functions to verify your tests produce the correct results. 30 | } 31 | 32 | - (void)testPerformanceExample { 33 | // This is an example of a performance test case. 34 | [self measureBlock:^{ 35 | // Put the code you want to measure the time of here. 36 | }]; 37 | } 38 | 39 | @end 40 | -------------------------------------------------------------------------------- /KIZBehaviorDemoUITests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /KIZBehaviorDemoUITests/KIZBehaviorDemoUITests.m: -------------------------------------------------------------------------------- 1 | // 2 | // KIZBehaviorDemoUITests.m 3 | // KIZBehaviorDemoUITests 4 | // 5 | // Created by kingizz on 15/10/31. 6 | // Copyright © 2015年 kingizz. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface KIZBehaviorDemoUITests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation KIZBehaviorDemoUITests 16 | 17 | - (void)setUp { 18 | [super setUp]; 19 | 20 | // Put setup code here. This method is called before the invocation of each test method in the class. 21 | 22 | // In UI tests it is usually best to stop immediately when a failure occurs. 23 | self.continueAfterFailure = NO; 24 | // UI tests must launch the application that they test. Doing this in setup will make sure it happens for each test method. 25 | [[[XCUIApplication alloc] init] launch]; 26 | 27 | // In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this. 28 | } 29 | 30 | - (void)tearDown { 31 | // Put teardown code here. This method is called after the invocation of each test method in the class. 32 | [super tearDown]; 33 | } 34 | 35 | - (void)testExample { 36 | // Use recording to get started writing UI tests. 37 | // Use XCTAssert and related functions to verify your tests produce the correct results. 38 | } 39 | 40 | @end 41 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 苏格拉没有底 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | KIZBehavior 2 | ================== 3 | 4 | KIZBehavior是基于组合设计模式,并且充分利用Interface Builder来实现某些功能的代码集,旨在通过低耦合、低侵入、组件化、少代码甚至无代码化的形式来实现一些功能。 5 | 6 | KIZBehavior遵循组合模式,代码遵循功能单一原则并且可以使我们的类简化,可以通过组合多个behavior来定制较为复杂的效果,并且在Interface Builder中提供丰富的参数设置,无需编码也可以通过参数来调整效果。 7 | 8 | 更多关于Behavior模式的信息请看这篇文章:[iOS中的行为](http://objccn.io/issue-13-3/) 英文原版:[Behaviors in iOS Apps](https://www.objc.io/issues/13-architecture/behaviors/) 9 | 10 | 目前KIZBehavior实现的功能有: 11 | 12 | 1. `KIZParallaxHeaderBehavior`: UIScrollView 头部图片视差效果 13 | 2. `KIZNavBarGradientBehavior`: NavigationBar 透明渐变动画效果 14 | 15 | ###KIZParallaxHeaderBehavior 16 | UIScrollView头部图片拉伸效果 17 | ####features 18 | 19 | - [x] 0行代码集成 20 | - [x] 图片等比例拉伸 21 | - [x] IB设置视差效果参数 22 | 23 | ####How to Use 24 | 在IB中设置UIScrollView的delegate为KIZParallaxHeaderBehavior即可 25 | 26 | ![parallax header](http://7xjsf4.com1.z0.glb.clouddn.com/git_KIZBehavior_parallax.gif) 27 | 28 | 29 | ###KIZNavBarGradientBehavior 30 | 导航栏渐变动画效果 31 | ####features: 32 | 33 | - [x] 导航栏透明度渐变 34 | - [x] 导航栏上文字及图表的颜色渐变 35 | - [x] 状态栏颜色变化 36 | - [x] 自动保存初始及离开界面时的状态,退出或返回界面时自动恢复原来状态 37 | - [x] IB设置相关参数 38 | 39 | ####How to use 40 | 在controller的`viewWillAppear ` 和 `viewWillDisappear `中分别调用两个方法,并且设置UISCrollView的delegate为KIZNavBarGradientBehavior即可 41 | 42 | ```Objective-C 43 | - (void)viewWillAppear:(BOOL)animated{ 44 | [super viewWillAppear:animated]; 45 | 46 | [self.navBarBehavior onViewWillAppear]; 47 | } 48 | 49 | - (void)viewWillDisappear:(BOOL)animated{ 50 | [super viewWillDisappear:animated]; 51 | 52 | [self.navBarBehavior onViewWillDisAppear]; 53 | } 54 | ``` 55 | 56 | ![NavigationBar animation](http://7xjsf4.com1.z0.glb.clouddn.com/git_KIZBehavior_navigationBar.gif) 57 | 58 | 59 | ###KIZParallaxHeaderBehavior + KIZNavBarGradientBehavior 60 | 组合效果 61 | ####How to use 62 | 需要设置UIScrollView的delegate为KIZMultipleProxyBehavior,并且将需要组合的behavior添加到MultipleProxyBehavior中即可。 63 | ![Parallax + NavigationBar](http://7xjsf4.com1.z0.glb.clouddn.com/git_KIZBehavior_parallax_nav.gif) 64 | --------------------------------------------------------------------------------