├── .gitignore ├── LICENSE ├── README.md └── VVeboImageView ├── VVeboImageView.xcodeproj ├── project.pbxproj └── project.xcworkspace │ └── contents.xcworkspacedata ├── VVeboImageView ├── 1.gif ├── 2.gif ├── AppDelegate.h ├── AppDelegate.m ├── Base.lproj │ └── Main.storyboard ├── Images.xcassets │ ├── AppIcon.appiconset │ │ └── Contents.json │ └── LaunchImage.launchimage │ │ └── Contents.json ├── VVeboImage.h ├── VVeboImage.m ├── VVeboImageTicker.h ├── VVeboImageTicker.m ├── VVeboImageView-Info.plist ├── VVeboImageView-Prefix.pch ├── VVeboImageView.h ├── VVeboImageView.m ├── ViewController.h ├── ViewController.m ├── en.lproj │ └── InfoPlist.strings └── main.m └── VVeboImageViewTests ├── VVeboImageViewTests-Info.plist ├── VVeboImageViewTests.m └── en.lproj └── InfoPlist.strings /.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 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | VVeboImageView 2 | ============== 3 | 4 | A UIImageView to play gif with low memory. 5 | -------------------------------------------------------------------------------- /VVeboImageView/VVeboImageView.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | C4A4A68F18D8047D000D06A2 /* VVeboImageTicker.m in Sources */ = {isa = PBXBuildFile; fileRef = C4A4A68E18D8047D000D06A2 /* VVeboImageTicker.m */; }; 11 | C4BDBD8E18C9C5DC0072AD6B /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C4BDBD8D18C9C5DC0072AD6B /* Foundation.framework */; }; 12 | C4BDBD9018C9C5DC0072AD6B /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C4BDBD8F18C9C5DC0072AD6B /* CoreGraphics.framework */; }; 13 | C4BDBD9218C9C5DC0072AD6B /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C4BDBD9118C9C5DC0072AD6B /* UIKit.framework */; }; 14 | C4BDBD9818C9C5DC0072AD6B /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = C4BDBD9618C9C5DC0072AD6B /* InfoPlist.strings */; }; 15 | C4BDBD9A18C9C5DC0072AD6B /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = C4BDBD9918C9C5DC0072AD6B /* main.m */; }; 16 | C4BDBD9E18C9C5DC0072AD6B /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = C4BDBD9D18C9C5DC0072AD6B /* AppDelegate.m */; }; 17 | C4BDBDA118C9C5DD0072AD6B /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = C4BDBD9F18C9C5DD0072AD6B /* Main.storyboard */; }; 18 | C4BDBDA418C9C5DD0072AD6B /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = C4BDBDA318C9C5DD0072AD6B /* ViewController.m */; }; 19 | C4BDBDA618C9C5DD0072AD6B /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = C4BDBDA518C9C5DD0072AD6B /* Images.xcassets */; }; 20 | C4BDBDAD18C9C5DD0072AD6B /* XCTest.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C4BDBDAC18C9C5DD0072AD6B /* XCTest.framework */; }; 21 | C4BDBDAE18C9C5DD0072AD6B /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C4BDBD8D18C9C5DC0072AD6B /* Foundation.framework */; }; 22 | C4BDBDAF18C9C5DD0072AD6B /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C4BDBD9118C9C5DC0072AD6B /* UIKit.framework */; }; 23 | C4BDBDB718C9C5DD0072AD6B /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = C4BDBDB518C9C5DD0072AD6B /* InfoPlist.strings */; }; 24 | C4BDBDB918C9C5DD0072AD6B /* VVeboImageViewTests.m in Sources */ = {isa = PBXBuildFile; fileRef = C4BDBDB818C9C5DD0072AD6B /* VVeboImageViewTests.m */; }; 25 | C4BDBDC618C9C6080072AD6B /* VVeboImageView.m in Sources */ = {isa = PBXBuildFile; fileRef = C4BDBDC318C9C6080072AD6B /* VVeboImageView.m */; }; 26 | C4BDBDC718C9C6080072AD6B /* VVeboImage.m in Sources */ = {isa = PBXBuildFile; fileRef = C4BDBDC518C9C6080072AD6B /* VVeboImage.m */; }; 27 | C4BDBDC918C9C87B0072AD6B /* 1.gif in Resources */ = {isa = PBXBuildFile; fileRef = C4BDBDC818C9C87B0072AD6B /* 1.gif */; }; 28 | C4BDBDCB18C9CA000072AD6B /* 2.gif in Resources */ = {isa = PBXBuildFile; fileRef = C4BDBDCA18C9CA000072AD6B /* 2.gif */; }; 29 | /* End PBXBuildFile section */ 30 | 31 | /* Begin PBXContainerItemProxy section */ 32 | C4BDBDB018C9C5DD0072AD6B /* PBXContainerItemProxy */ = { 33 | isa = PBXContainerItemProxy; 34 | containerPortal = C4BDBD8218C9C5DC0072AD6B /* Project object */; 35 | proxyType = 1; 36 | remoteGlobalIDString = C4BDBD8918C9C5DC0072AD6B; 37 | remoteInfo = VVeboImageView; 38 | }; 39 | /* End PBXContainerItemProxy section */ 40 | 41 | /* Begin PBXFileReference section */ 42 | C4A4A68D18D8047D000D06A2 /* VVeboImageTicker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VVeboImageTicker.h; sourceTree = ""; }; 43 | C4A4A68E18D8047D000D06A2 /* VVeboImageTicker.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = VVeboImageTicker.m; sourceTree = ""; }; 44 | C4BDBD8A18C9C5DC0072AD6B /* VVeboImageView.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = VVeboImageView.app; sourceTree = BUILT_PRODUCTS_DIR; }; 45 | C4BDBD8D18C9C5DC0072AD6B /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; 46 | C4BDBD8F18C9C5DC0072AD6B /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; 47 | C4BDBD9118C9C5DC0072AD6B /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; 48 | C4BDBD9518C9C5DC0072AD6B /* VVeboImageView-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "VVeboImageView-Info.plist"; sourceTree = ""; }; 49 | C4BDBD9718C9C5DC0072AD6B /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; 50 | C4BDBD9918C9C5DC0072AD6B /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 51 | C4BDBD9B18C9C5DC0072AD6B /* VVeboImageView-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "VVeboImageView-Prefix.pch"; sourceTree = ""; }; 52 | C4BDBD9C18C9C5DC0072AD6B /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 53 | C4BDBD9D18C9C5DC0072AD6B /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 54 | C4BDBDA018C9C5DD0072AD6B /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 55 | C4BDBDA218C9C5DD0072AD6B /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; 56 | C4BDBDA318C9C5DD0072AD6B /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; 57 | C4BDBDA518C9C5DD0072AD6B /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; 58 | C4BDBDAB18C9C5DD0072AD6B /* VVeboImageViewTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = VVeboImageViewTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 59 | C4BDBDAC18C9C5DD0072AD6B /* XCTest.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = XCTest.framework; path = Library/Frameworks/XCTest.framework; sourceTree = DEVELOPER_DIR; }; 60 | C4BDBDB418C9C5DD0072AD6B /* VVeboImageViewTests-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "VVeboImageViewTests-Info.plist"; sourceTree = ""; }; 61 | C4BDBDB618C9C5DD0072AD6B /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; 62 | C4BDBDB818C9C5DD0072AD6B /* VVeboImageViewTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = VVeboImageViewTests.m; sourceTree = ""; }; 63 | C4BDBDC218C9C6080072AD6B /* VVeboImageView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VVeboImageView.h; sourceTree = ""; }; 64 | C4BDBDC318C9C6080072AD6B /* VVeboImageView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = VVeboImageView.m; sourceTree = ""; }; 65 | C4BDBDC418C9C6080072AD6B /* VVeboImage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VVeboImage.h; sourceTree = ""; }; 66 | C4BDBDC518C9C6080072AD6B /* VVeboImage.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = VVeboImage.m; sourceTree = ""; }; 67 | C4BDBDC818C9C87B0072AD6B /* 1.gif */ = {isa = PBXFileReference; lastKnownFileType = image.gif; path = 1.gif; sourceTree = ""; }; 68 | C4BDBDCA18C9CA000072AD6B /* 2.gif */ = {isa = PBXFileReference; lastKnownFileType = image.gif; path = 2.gif; sourceTree = ""; }; 69 | /* End PBXFileReference section */ 70 | 71 | /* Begin PBXFrameworksBuildPhase section */ 72 | C4BDBD8718C9C5DC0072AD6B /* Frameworks */ = { 73 | isa = PBXFrameworksBuildPhase; 74 | buildActionMask = 2147483647; 75 | files = ( 76 | C4BDBD9018C9C5DC0072AD6B /* CoreGraphics.framework in Frameworks */, 77 | C4BDBD9218C9C5DC0072AD6B /* UIKit.framework in Frameworks */, 78 | C4BDBD8E18C9C5DC0072AD6B /* Foundation.framework in Frameworks */, 79 | ); 80 | runOnlyForDeploymentPostprocessing = 0; 81 | }; 82 | C4BDBDA818C9C5DD0072AD6B /* Frameworks */ = { 83 | isa = PBXFrameworksBuildPhase; 84 | buildActionMask = 2147483647; 85 | files = ( 86 | C4BDBDAD18C9C5DD0072AD6B /* XCTest.framework in Frameworks */, 87 | C4BDBDAF18C9C5DD0072AD6B /* UIKit.framework in Frameworks */, 88 | C4BDBDAE18C9C5DD0072AD6B /* Foundation.framework in Frameworks */, 89 | ); 90 | runOnlyForDeploymentPostprocessing = 0; 91 | }; 92 | /* End PBXFrameworksBuildPhase section */ 93 | 94 | /* Begin PBXGroup section */ 95 | C4BDBD8118C9C5DC0072AD6B = { 96 | isa = PBXGroup; 97 | children = ( 98 | C4BDBD9318C9C5DC0072AD6B /* VVeboImageView */, 99 | C4BDBDB218C9C5DD0072AD6B /* VVeboImageViewTests */, 100 | C4BDBD8C18C9C5DC0072AD6B /* Frameworks */, 101 | C4BDBD8B18C9C5DC0072AD6B /* Products */, 102 | ); 103 | sourceTree = ""; 104 | }; 105 | C4BDBD8B18C9C5DC0072AD6B /* Products */ = { 106 | isa = PBXGroup; 107 | children = ( 108 | C4BDBD8A18C9C5DC0072AD6B /* VVeboImageView.app */, 109 | C4BDBDAB18C9C5DD0072AD6B /* VVeboImageViewTests.xctest */, 110 | ); 111 | name = Products; 112 | sourceTree = ""; 113 | }; 114 | C4BDBD8C18C9C5DC0072AD6B /* Frameworks */ = { 115 | isa = PBXGroup; 116 | children = ( 117 | C4BDBD8D18C9C5DC0072AD6B /* Foundation.framework */, 118 | C4BDBD8F18C9C5DC0072AD6B /* CoreGraphics.framework */, 119 | C4BDBD9118C9C5DC0072AD6B /* UIKit.framework */, 120 | C4BDBDAC18C9C5DD0072AD6B /* XCTest.framework */, 121 | ); 122 | name = Frameworks; 123 | sourceTree = ""; 124 | }; 125 | C4BDBD9318C9C5DC0072AD6B /* VVeboImageView */ = { 126 | isa = PBXGroup; 127 | children = ( 128 | C4A4A68D18D8047D000D06A2 /* VVeboImageTicker.h */, 129 | C4A4A68E18D8047D000D06A2 /* VVeboImageTicker.m */, 130 | C4BDBDC218C9C6080072AD6B /* VVeboImageView.h */, 131 | C4BDBDC318C9C6080072AD6B /* VVeboImageView.m */, 132 | C4BDBDC418C9C6080072AD6B /* VVeboImage.h */, 133 | C4BDBDC518C9C6080072AD6B /* VVeboImage.m */, 134 | C4BDBD9C18C9C5DC0072AD6B /* AppDelegate.h */, 135 | C4BDBD9D18C9C5DC0072AD6B /* AppDelegate.m */, 136 | C4BDBD9F18C9C5DD0072AD6B /* Main.storyboard */, 137 | C4BDBDA218C9C5DD0072AD6B /* ViewController.h */, 138 | C4BDBDA318C9C5DD0072AD6B /* ViewController.m */, 139 | C4BDBDA518C9C5DD0072AD6B /* Images.xcassets */, 140 | C4BDBD9418C9C5DC0072AD6B /* Supporting Files */, 141 | ); 142 | path = VVeboImageView; 143 | sourceTree = ""; 144 | }; 145 | C4BDBD9418C9C5DC0072AD6B /* Supporting Files */ = { 146 | isa = PBXGroup; 147 | children = ( 148 | C4BDBDC818C9C87B0072AD6B /* 1.gif */, 149 | C4BDBDCA18C9CA000072AD6B /* 2.gif */, 150 | C4BDBD9518C9C5DC0072AD6B /* VVeboImageView-Info.plist */, 151 | C4BDBD9618C9C5DC0072AD6B /* InfoPlist.strings */, 152 | C4BDBD9918C9C5DC0072AD6B /* main.m */, 153 | C4BDBD9B18C9C5DC0072AD6B /* VVeboImageView-Prefix.pch */, 154 | ); 155 | name = "Supporting Files"; 156 | sourceTree = ""; 157 | }; 158 | C4BDBDB218C9C5DD0072AD6B /* VVeboImageViewTests */ = { 159 | isa = PBXGroup; 160 | children = ( 161 | C4BDBDB818C9C5DD0072AD6B /* VVeboImageViewTests.m */, 162 | C4BDBDB318C9C5DD0072AD6B /* Supporting Files */, 163 | ); 164 | path = VVeboImageViewTests; 165 | sourceTree = ""; 166 | }; 167 | C4BDBDB318C9C5DD0072AD6B /* Supporting Files */ = { 168 | isa = PBXGroup; 169 | children = ( 170 | C4BDBDB418C9C5DD0072AD6B /* VVeboImageViewTests-Info.plist */, 171 | C4BDBDB518C9C5DD0072AD6B /* InfoPlist.strings */, 172 | ); 173 | name = "Supporting Files"; 174 | sourceTree = ""; 175 | }; 176 | /* End PBXGroup section */ 177 | 178 | /* Begin PBXNativeTarget section */ 179 | C4BDBD8918C9C5DC0072AD6B /* VVeboImageView */ = { 180 | isa = PBXNativeTarget; 181 | buildConfigurationList = C4BDBDBC18C9C5DD0072AD6B /* Build configuration list for PBXNativeTarget "VVeboImageView" */; 182 | buildPhases = ( 183 | C4BDBD8618C9C5DC0072AD6B /* Sources */, 184 | C4BDBD8718C9C5DC0072AD6B /* Frameworks */, 185 | C4BDBD8818C9C5DC0072AD6B /* Resources */, 186 | ); 187 | buildRules = ( 188 | ); 189 | dependencies = ( 190 | ); 191 | name = VVeboImageView; 192 | productName = VVeboImageView; 193 | productReference = C4BDBD8A18C9C5DC0072AD6B /* VVeboImageView.app */; 194 | productType = "com.apple.product-type.application"; 195 | }; 196 | C4BDBDAA18C9C5DD0072AD6B /* VVeboImageViewTests */ = { 197 | isa = PBXNativeTarget; 198 | buildConfigurationList = C4BDBDBF18C9C5DD0072AD6B /* Build configuration list for PBXNativeTarget "VVeboImageViewTests" */; 199 | buildPhases = ( 200 | C4BDBDA718C9C5DD0072AD6B /* Sources */, 201 | C4BDBDA818C9C5DD0072AD6B /* Frameworks */, 202 | C4BDBDA918C9C5DD0072AD6B /* Resources */, 203 | ); 204 | buildRules = ( 205 | ); 206 | dependencies = ( 207 | C4BDBDB118C9C5DD0072AD6B /* PBXTargetDependency */, 208 | ); 209 | name = VVeboImageViewTests; 210 | productName = VVeboImageViewTests; 211 | productReference = C4BDBDAB18C9C5DD0072AD6B /* VVeboImageViewTests.xctest */; 212 | productType = "com.apple.product-type.bundle.unit-test"; 213 | }; 214 | /* End PBXNativeTarget section */ 215 | 216 | /* Begin PBXProject section */ 217 | C4BDBD8218C9C5DC0072AD6B /* Project object */ = { 218 | isa = PBXProject; 219 | attributes = { 220 | LastUpgradeCheck = 0500; 221 | ORGANIZATIONNAME = Johnil; 222 | TargetAttributes = { 223 | C4BDBDAA18C9C5DD0072AD6B = { 224 | TestTargetID = C4BDBD8918C9C5DC0072AD6B; 225 | }; 226 | }; 227 | }; 228 | buildConfigurationList = C4BDBD8518C9C5DC0072AD6B /* Build configuration list for PBXProject "VVeboImageView" */; 229 | compatibilityVersion = "Xcode 3.2"; 230 | developmentRegion = English; 231 | hasScannedForEncodings = 0; 232 | knownRegions = ( 233 | en, 234 | Base, 235 | ); 236 | mainGroup = C4BDBD8118C9C5DC0072AD6B; 237 | productRefGroup = C4BDBD8B18C9C5DC0072AD6B /* Products */; 238 | projectDirPath = ""; 239 | projectRoot = ""; 240 | targets = ( 241 | C4BDBD8918C9C5DC0072AD6B /* VVeboImageView */, 242 | C4BDBDAA18C9C5DD0072AD6B /* VVeboImageViewTests */, 243 | ); 244 | }; 245 | /* End PBXProject section */ 246 | 247 | /* Begin PBXResourcesBuildPhase section */ 248 | C4BDBD8818C9C5DC0072AD6B /* Resources */ = { 249 | isa = PBXResourcesBuildPhase; 250 | buildActionMask = 2147483647; 251 | files = ( 252 | C4BDBDC918C9C87B0072AD6B /* 1.gif in Resources */, 253 | C4BDBDA618C9C5DD0072AD6B /* Images.xcassets in Resources */, 254 | C4BDBDCB18C9CA000072AD6B /* 2.gif in Resources */, 255 | C4BDBD9818C9C5DC0072AD6B /* InfoPlist.strings in Resources */, 256 | C4BDBDA118C9C5DD0072AD6B /* Main.storyboard in Resources */, 257 | ); 258 | runOnlyForDeploymentPostprocessing = 0; 259 | }; 260 | C4BDBDA918C9C5DD0072AD6B /* Resources */ = { 261 | isa = PBXResourcesBuildPhase; 262 | buildActionMask = 2147483647; 263 | files = ( 264 | C4BDBDB718C9C5DD0072AD6B /* InfoPlist.strings in Resources */, 265 | ); 266 | runOnlyForDeploymentPostprocessing = 0; 267 | }; 268 | /* End PBXResourcesBuildPhase section */ 269 | 270 | /* Begin PBXSourcesBuildPhase section */ 271 | C4BDBD8618C9C5DC0072AD6B /* Sources */ = { 272 | isa = PBXSourcesBuildPhase; 273 | buildActionMask = 2147483647; 274 | files = ( 275 | C4BDBDA418C9C5DD0072AD6B /* ViewController.m in Sources */, 276 | C4BDBD9E18C9C5DC0072AD6B /* AppDelegate.m in Sources */, 277 | C4BDBD9A18C9C5DC0072AD6B /* main.m in Sources */, 278 | C4BDBDC618C9C6080072AD6B /* VVeboImageView.m in Sources */, 279 | C4A4A68F18D8047D000D06A2 /* VVeboImageTicker.m in Sources */, 280 | C4BDBDC718C9C6080072AD6B /* VVeboImage.m in Sources */, 281 | ); 282 | runOnlyForDeploymentPostprocessing = 0; 283 | }; 284 | C4BDBDA718C9C5DD0072AD6B /* Sources */ = { 285 | isa = PBXSourcesBuildPhase; 286 | buildActionMask = 2147483647; 287 | files = ( 288 | C4BDBDB918C9C5DD0072AD6B /* VVeboImageViewTests.m in Sources */, 289 | ); 290 | runOnlyForDeploymentPostprocessing = 0; 291 | }; 292 | /* End PBXSourcesBuildPhase section */ 293 | 294 | /* Begin PBXTargetDependency section */ 295 | C4BDBDB118C9C5DD0072AD6B /* PBXTargetDependency */ = { 296 | isa = PBXTargetDependency; 297 | target = C4BDBD8918C9C5DC0072AD6B /* VVeboImageView */; 298 | targetProxy = C4BDBDB018C9C5DD0072AD6B /* PBXContainerItemProxy */; 299 | }; 300 | /* End PBXTargetDependency section */ 301 | 302 | /* Begin PBXVariantGroup section */ 303 | C4BDBD9618C9C5DC0072AD6B /* InfoPlist.strings */ = { 304 | isa = PBXVariantGroup; 305 | children = ( 306 | C4BDBD9718C9C5DC0072AD6B /* en */, 307 | ); 308 | name = InfoPlist.strings; 309 | sourceTree = ""; 310 | }; 311 | C4BDBD9F18C9C5DD0072AD6B /* Main.storyboard */ = { 312 | isa = PBXVariantGroup; 313 | children = ( 314 | C4BDBDA018C9C5DD0072AD6B /* Base */, 315 | ); 316 | name = Main.storyboard; 317 | sourceTree = ""; 318 | }; 319 | C4BDBDB518C9C5DD0072AD6B /* InfoPlist.strings */ = { 320 | isa = PBXVariantGroup; 321 | children = ( 322 | C4BDBDB618C9C5DD0072AD6B /* en */, 323 | ); 324 | name = InfoPlist.strings; 325 | sourceTree = ""; 326 | }; 327 | /* End PBXVariantGroup section */ 328 | 329 | /* Begin XCBuildConfiguration section */ 330 | C4BDBDBA18C9C5DD0072AD6B /* Debug */ = { 331 | isa = XCBuildConfiguration; 332 | buildSettings = { 333 | ALWAYS_SEARCH_USER_PATHS = NO; 334 | ARCHS = "$(ARCHS_STANDARD_INCLUDING_64_BIT)"; 335 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 336 | CLANG_CXX_LIBRARY = "libc++"; 337 | CLANG_ENABLE_MODULES = YES; 338 | CLANG_ENABLE_OBJC_ARC = YES; 339 | CLANG_WARN_BOOL_CONVERSION = YES; 340 | CLANG_WARN_CONSTANT_CONVERSION = YES; 341 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 342 | CLANG_WARN_EMPTY_BODY = YES; 343 | CLANG_WARN_ENUM_CONVERSION = YES; 344 | CLANG_WARN_INT_CONVERSION = YES; 345 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 346 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 347 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 348 | COPY_PHASE_STRIP = NO; 349 | GCC_C_LANGUAGE_STANDARD = gnu99; 350 | GCC_DYNAMIC_NO_PIC = NO; 351 | GCC_OPTIMIZATION_LEVEL = 0; 352 | GCC_PREPROCESSOR_DEFINITIONS = ( 353 | "DEBUG=1", 354 | "$(inherited)", 355 | ); 356 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 357 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 358 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 359 | GCC_WARN_UNDECLARED_SELECTOR = YES; 360 | GCC_WARN_UNINITIALIZED_AUTOS = YES; 361 | GCC_WARN_UNUSED_FUNCTION = YES; 362 | GCC_WARN_UNUSED_VARIABLE = YES; 363 | IPHONEOS_DEPLOYMENT_TARGET = 7.0; 364 | ONLY_ACTIVE_ARCH = YES; 365 | SDKROOT = iphoneos; 366 | }; 367 | name = Debug; 368 | }; 369 | C4BDBDBB18C9C5DD0072AD6B /* Release */ = { 370 | isa = XCBuildConfiguration; 371 | buildSettings = { 372 | ALWAYS_SEARCH_USER_PATHS = NO; 373 | ARCHS = "$(ARCHS_STANDARD_INCLUDING_64_BIT)"; 374 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 375 | CLANG_CXX_LIBRARY = "libc++"; 376 | CLANG_ENABLE_MODULES = YES; 377 | CLANG_ENABLE_OBJC_ARC = YES; 378 | CLANG_WARN_BOOL_CONVERSION = YES; 379 | CLANG_WARN_CONSTANT_CONVERSION = YES; 380 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 381 | CLANG_WARN_EMPTY_BODY = YES; 382 | CLANG_WARN_ENUM_CONVERSION = YES; 383 | CLANG_WARN_INT_CONVERSION = YES; 384 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 385 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 386 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 387 | COPY_PHASE_STRIP = YES; 388 | ENABLE_NS_ASSERTIONS = NO; 389 | GCC_C_LANGUAGE_STANDARD = gnu99; 390 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 391 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 392 | GCC_WARN_UNDECLARED_SELECTOR = YES; 393 | GCC_WARN_UNINITIALIZED_AUTOS = YES; 394 | GCC_WARN_UNUSED_FUNCTION = YES; 395 | GCC_WARN_UNUSED_VARIABLE = YES; 396 | IPHONEOS_DEPLOYMENT_TARGET = 7.0; 397 | SDKROOT = iphoneos; 398 | VALIDATE_PRODUCT = YES; 399 | }; 400 | name = Release; 401 | }; 402 | C4BDBDBD18C9C5DD0072AD6B /* Debug */ = { 403 | isa = XCBuildConfiguration; 404 | buildSettings = { 405 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 406 | ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; 407 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 408 | GCC_PREFIX_HEADER = "VVeboImageView/VVeboImageView-Prefix.pch"; 409 | INFOPLIST_FILE = "VVeboImageView/VVeboImageView-Info.plist"; 410 | PRODUCT_NAME = "$(TARGET_NAME)"; 411 | WRAPPER_EXTENSION = app; 412 | }; 413 | name = Debug; 414 | }; 415 | C4BDBDBE18C9C5DD0072AD6B /* Release */ = { 416 | isa = XCBuildConfiguration; 417 | buildSettings = { 418 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 419 | ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; 420 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 421 | GCC_PREFIX_HEADER = "VVeboImageView/VVeboImageView-Prefix.pch"; 422 | INFOPLIST_FILE = "VVeboImageView/VVeboImageView-Info.plist"; 423 | PRODUCT_NAME = "$(TARGET_NAME)"; 424 | WRAPPER_EXTENSION = app; 425 | }; 426 | name = Release; 427 | }; 428 | C4BDBDC018C9C5DD0072AD6B /* Debug */ = { 429 | isa = XCBuildConfiguration; 430 | buildSettings = { 431 | ARCHS = "$(ARCHS_STANDARD_INCLUDING_64_BIT)"; 432 | BUNDLE_LOADER = "$(BUILT_PRODUCTS_DIR)/VVeboImageView.app/VVeboImageView"; 433 | FRAMEWORK_SEARCH_PATHS = ( 434 | "$(SDKROOT)/Developer/Library/Frameworks", 435 | "$(inherited)", 436 | "$(DEVELOPER_FRAMEWORKS_DIR)", 437 | ); 438 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 439 | GCC_PREFIX_HEADER = "VVeboImageView/VVeboImageView-Prefix.pch"; 440 | GCC_PREPROCESSOR_DEFINITIONS = ( 441 | "DEBUG=1", 442 | "$(inherited)", 443 | ); 444 | INFOPLIST_FILE = "VVeboImageViewTests/VVeboImageViewTests-Info.plist"; 445 | PRODUCT_NAME = "$(TARGET_NAME)"; 446 | TEST_HOST = "$(BUNDLE_LOADER)"; 447 | WRAPPER_EXTENSION = xctest; 448 | }; 449 | name = Debug; 450 | }; 451 | C4BDBDC118C9C5DD0072AD6B /* Release */ = { 452 | isa = XCBuildConfiguration; 453 | buildSettings = { 454 | ARCHS = "$(ARCHS_STANDARD_INCLUDING_64_BIT)"; 455 | BUNDLE_LOADER = "$(BUILT_PRODUCTS_DIR)/VVeboImageView.app/VVeboImageView"; 456 | FRAMEWORK_SEARCH_PATHS = ( 457 | "$(SDKROOT)/Developer/Library/Frameworks", 458 | "$(inherited)", 459 | "$(DEVELOPER_FRAMEWORKS_DIR)", 460 | ); 461 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 462 | GCC_PREFIX_HEADER = "VVeboImageView/VVeboImageView-Prefix.pch"; 463 | INFOPLIST_FILE = "VVeboImageViewTests/VVeboImageViewTests-Info.plist"; 464 | PRODUCT_NAME = "$(TARGET_NAME)"; 465 | TEST_HOST = "$(BUNDLE_LOADER)"; 466 | WRAPPER_EXTENSION = xctest; 467 | }; 468 | name = Release; 469 | }; 470 | /* End XCBuildConfiguration section */ 471 | 472 | /* Begin XCConfigurationList section */ 473 | C4BDBD8518C9C5DC0072AD6B /* Build configuration list for PBXProject "VVeboImageView" */ = { 474 | isa = XCConfigurationList; 475 | buildConfigurations = ( 476 | C4BDBDBA18C9C5DD0072AD6B /* Debug */, 477 | C4BDBDBB18C9C5DD0072AD6B /* Release */, 478 | ); 479 | defaultConfigurationIsVisible = 0; 480 | defaultConfigurationName = Release; 481 | }; 482 | C4BDBDBC18C9C5DD0072AD6B /* Build configuration list for PBXNativeTarget "VVeboImageView" */ = { 483 | isa = XCConfigurationList; 484 | buildConfigurations = ( 485 | C4BDBDBD18C9C5DD0072AD6B /* Debug */, 486 | C4BDBDBE18C9C5DD0072AD6B /* Release */, 487 | ); 488 | defaultConfigurationIsVisible = 0; 489 | defaultConfigurationName = Release; 490 | }; 491 | C4BDBDBF18C9C5DD0072AD6B /* Build configuration list for PBXNativeTarget "VVeboImageViewTests" */ = { 492 | isa = XCConfigurationList; 493 | buildConfigurations = ( 494 | C4BDBDC018C9C5DD0072AD6B /* Debug */, 495 | C4BDBDC118C9C5DD0072AD6B /* Release */, 496 | ); 497 | defaultConfigurationIsVisible = 0; 498 | defaultConfigurationName = Release; 499 | }; 500 | /* End XCConfigurationList section */ 501 | }; 502 | rootObject = C4BDBD8218C9C5DC0072AD6B /* Project object */; 503 | } 504 | -------------------------------------------------------------------------------- /VVeboImageView/VVeboImageView.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /VVeboImageView/VVeboImageView/1.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/johnil/VVeboImageView/b59f69634467b9982210daae9e3542156cdaf154/VVeboImageView/VVeboImageView/1.gif -------------------------------------------------------------------------------- /VVeboImageView/VVeboImageView/2.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/johnil/VVeboImageView/b59f69634467b9982210daae9e3542156cdaf154/VVeboImageView/VVeboImageView/2.gif -------------------------------------------------------------------------------- /VVeboImageView/VVeboImageView/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // VVeboImageView 4 | // 5 | // Created by Johnil on 14-3-7. 6 | // Copyright (c) 2014年 Johnil. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /VVeboImageView/VVeboImageView/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // VVeboImageView 4 | // 5 | // Created by Johnil on 14-3-7. 6 | // Copyright (c) 2014年 Johnil. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | 11 | @implementation AppDelegate 12 | 13 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 14 | { 15 | // Override point for customization after application launch. 16 | return YES; 17 | } 18 | 19 | - (void)applicationWillResignActive:(UIApplication *)application 20 | { 21 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 22 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. 23 | } 24 | 25 | - (void)applicationDidEnterBackground:(UIApplication *)application 26 | { 27 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 28 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 29 | } 30 | 31 | - (void)applicationWillEnterForeground:(UIApplication *)application 32 | { 33 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. 34 | } 35 | 36 | - (void)applicationDidBecomeActive:(UIApplication *)application 37 | { 38 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 39 | } 40 | 41 | - (void)applicationWillTerminate:(UIApplication *)application 42 | { 43 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 44 | } 45 | 46 | @end 47 | -------------------------------------------------------------------------------- /VVeboImageView/VVeboImageView/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 | -------------------------------------------------------------------------------- /VVeboImageView/VVeboImageView/Images.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" : "40x40", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "60x60", 16 | "scale" : "2x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } -------------------------------------------------------------------------------- /VVeboImageView/VVeboImageView/Images.xcassets/LaunchImage.launchimage/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "orientation" : "portrait", 5 | "idiom" : "iphone", 6 | "extent" : "full-screen", 7 | "minimum-system-version" : "7.0", 8 | "scale" : "2x" 9 | }, 10 | { 11 | "orientation" : "portrait", 12 | "idiom" : "iphone", 13 | "subtype" : "retina4", 14 | "extent" : "full-screen", 15 | "minimum-system-version" : "7.0", 16 | "scale" : "2x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } -------------------------------------------------------------------------------- /VVeboImageView/VVeboImageView/VVeboImage.h: -------------------------------------------------------------------------------- 1 | // 2 | // VVeboImage.h 3 | // vvebo 4 | // 5 | // Created by Johnil on 14-3-6. 6 | // Copyright (c) 2014年 Johnil. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface VVeboImage : UIImage 12 | 13 | + (VVeboImage *)gifWithData:(NSData *)data; 14 | - (UIImage *)nextImage; 15 | - (int)count; 16 | - (float)frameDuration; 17 | - (void)resumeIndex; 18 | 19 | @end 20 | -------------------------------------------------------------------------------- /VVeboImageView/VVeboImageView/VVeboImage.m: -------------------------------------------------------------------------------- 1 | // 2 | // VVeboImage.m 3 | // vvebo 4 | // 5 | // Created by Johnil on 14-3-6. 6 | // Copyright (c) 2014年 Johnil. All rights reserved. 7 | // 8 | 9 | #import "VVeboImage.h" 10 | 11 | #import 12 | 13 | @implementation VVeboImage { 14 | NSData *data; 15 | int index; 16 | CGImageSourceRef source; 17 | size_t count; 18 | } 19 | 20 | + (VVeboImage *)gifWithData:(NSData *)data{ 21 | VVeboImage *image = [[VVeboImage alloc] initGifWithData:data]; 22 | return image; 23 | } 24 | 25 | - (VVeboImage *)initGifWithData:(NSData *)data1{ 26 | index = 0; 27 | data = data1; 28 | source = CGImageSourceCreateWithData((__bridge CFDataRef)data, NULL); 29 | count = CGImageSourceGetCount(source); 30 | if (count<=1) { 31 | self = [super initWithData:data1]; 32 | return self; 33 | } else { 34 | CGImageRef image = CGImageSourceCreateImageAtIndex(source, index, NULL); 35 | self = [super initWithCGImage:image scale:[UIScreen mainScreen].scale orientation:UIImageOrientationUp]; 36 | CGImageRelease(image); 37 | } 38 | if (self) { 39 | NSLog(@"init with gif count %zu %@", count, self); 40 | } 41 | return self; 42 | } 43 | 44 | - (void)resumeIndex{ 45 | index-=20; 46 | if (index<0) { 47 | index = 0; 48 | } 49 | } 50 | 51 | //每侦的时间 52 | - (float)frameDuration { 53 | float frameDuration = 0.1f; 54 | CFDictionaryRef cfFrameProperties = CGImageSourceCopyPropertiesAtIndex(source, index, nil); 55 | NSDictionary *frameProperties = (__bridge NSDictionary *)cfFrameProperties; 56 | NSDictionary *gifProperties = frameProperties[(NSString *)kCGImagePropertyGIFDictionary]; 57 | 58 | NSNumber *delayTimeUnclampedProp = gifProperties[(NSString *)kCGImagePropertyGIFUnclampedDelayTime]; 59 | if (delayTimeUnclampedProp) { 60 | frameDuration = [delayTimeUnclampedProp floatValue]; 61 | } else { 62 | NSNumber *delayTimeProp = gifProperties[(NSString *)kCGImagePropertyGIFDelayTime]; 63 | if (delayTimeProp) { 64 | frameDuration = [delayTimeProp floatValue]; 65 | } 66 | } 67 | 68 | if (frameDuration < 0.011f) { 69 | frameDuration = 0.100f; 70 | } 71 | 72 | if (cfFrameProperties) { 73 | CFRelease(cfFrameProperties); 74 | } 75 | return frameDuration; 76 | } 77 | 78 | - (int)count{ 79 | return count; 80 | } 81 | 82 | - (UIImage *)nextImage{ 83 | CGImageRef image = CGImageSourceCreateImageAtIndex(source, index, NULL); 84 | UIImage *result = [UIImage imageWithCGImage:image scale:[UIScreen mainScreen].scale orientation:UIImageOrientationUp]; 85 | CGImageRelease(image); 86 | index++; 87 | if (index>count-1) { 88 | index=0; 89 | } 90 | return result; 91 | } 92 | 93 | - (void)dealloc{ 94 | if (data) { 95 | CFRelease(source); 96 | data = nil; 97 | } 98 | NSLog(@"gif release %@", self); 99 | } 100 | 101 | @end -------------------------------------------------------------------------------- /VVeboImageView/VVeboImageView/VVeboImageTicker.h: -------------------------------------------------------------------------------- 1 | // 2 | // VVeboImageTicker.h 3 | // VVeboImageView 4 | // 5 | // Created by Johnil on 14-3-18. 6 | // Copyright (c) 2014年 Johnil. All rights reserved. 7 | // 8 | #import 9 | @class VVeboImageView; 10 | #define tickStep 0.03f 11 | @interface VVeboImageTicker : NSObject 12 | 13 | + (VVeboImageTicker *)sharedInstance; 14 | - (void)tickView:(VVeboImageView *)imageView; 15 | - (void)unTickView:(VVeboImageView *)imageView; 16 | 17 | @end 18 | -------------------------------------------------------------------------------- /VVeboImageView/VVeboImageView/VVeboImageTicker.m: -------------------------------------------------------------------------------- 1 | // 2 | // VVeboImageTicker.m 3 | // VVeboImageView 4 | // 5 | // Created by Johnil on 14-3-18. 6 | // Copyright (c) 2014年 Johnil. All rights reserved. 7 | // 8 | 9 | #import "VVeboImageTicker.h" 10 | #import "VVeboImageView.h" 11 | 12 | @implementation VVeboImageTicker { 13 | CADisplayLink *timer; 14 | NSMutableArray *gifsView; 15 | } 16 | 17 | + (VVeboImageTicker *)sharedInstance 18 | { 19 | static VVeboImageTicker *sharedInstance = nil; 20 | if (sharedInstance == nil) 21 | { 22 | sharedInstance = [[VVeboImageTicker alloc] init]; 23 | } 24 | return sharedInstance; 25 | } 26 | 27 | - (id)init{ 28 | self = [super init]; 29 | if (self) { 30 | gifsView = [[NSMutableArray alloc] init]; 31 | [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(stopTimer) name:UIApplicationDidEnterBackgroundNotification object:nil]; 32 | [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(startTimer) name:UIApplicationDidBecomeActiveNotification object:nil]; 33 | } 34 | return self; 35 | } 36 | 37 | - (void)startTimer{ 38 | if (gifsView.count<=0) { 39 | return; 40 | } 41 | [self stopTimer]; 42 | timer = [CADisplayLink displayLinkWithTarget:self selector:@selector(tick)]; 43 | timer.frameInterval = tickStep; 44 | [timer addToRunLoop:[NSRunLoop currentRunLoop] forMode:NSRunLoopCommonModes]; 45 | } 46 | 47 | - (void)stopTimer{ 48 | if (timer) { 49 | [timer invalidate]; 50 | timer = nil; 51 | } 52 | } 53 | 54 | - (void)tickView:(VVeboImageView *)imageView{ 55 | if ([gifsView indexOfObject:imageView]==NSNotFound) { 56 | [gifsView addObject:imageView]; 57 | } 58 | if (gifsView.count>0&&timer==nil) { 59 | [self startTimer]; 60 | } 61 | } 62 | 63 | - (void)unTickView:(VVeboImageView *)imageView{ 64 | [gifsView removeObject:imageView]; 65 | if (gifsView.count<=0&&timer!=nil) { 66 | [self stopTimer]; 67 | } 68 | } 69 | 70 | - (void)tick{ 71 | [gifsView makeObjectsPerformSelector:@selector(playNext)]; 72 | } 73 | 74 | @end 75 | -------------------------------------------------------------------------------- /VVeboImageView/VVeboImageView/VVeboImageView-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleDisplayName 8 | ${PRODUCT_NAME} 9 | CFBundleExecutable 10 | ${EXECUTABLE_NAME} 11 | CFBundleIdentifier 12 | com.johnil.${PRODUCT_NAME:rfc1034identifier} 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | ${PRODUCT_NAME} 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 1.0 25 | LSRequiresIPhoneOS 26 | 27 | UIMainStoryboardFile 28 | Main 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | UIInterfaceOrientationLandscapeLeft 37 | UIInterfaceOrientationLandscapeRight 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /VVeboImageView/VVeboImageView/VVeboImageView-Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header 3 | // 4 | // The contents of this file are implicitly included at the beginning of every source file. 5 | // 6 | 7 | #import 8 | 9 | #ifndef __IPHONE_5_0 10 | #warning "This project uses features only available in iOS SDK 5.0 and later." 11 | #endif 12 | 13 | #ifdef __OBJC__ 14 | #import 15 | #import 16 | #endif 17 | -------------------------------------------------------------------------------- /VVeboImageView/VVeboImageView/VVeboImageView.h: -------------------------------------------------------------------------------- 1 | // 2 | // VVeboImageView.h 3 | // vvebo 4 | // 5 | // Created by Johnil on 14-3-6. 6 | // Copyright (c) 2014年 Johnil. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "VVeboImage.h" 11 | 12 | @interface VVeboImageView : UIImageView 13 | 14 | @property (nonatomic) float frameDuration; 15 | @property (nonatomic) float currentDuration; 16 | - (void)playNext; 17 | - (void)playGif; 18 | - (void)pauseGif; 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /VVeboImageView/VVeboImageView/VVeboImageView.m: -------------------------------------------------------------------------------- 1 | // 2 | // VVeboImageView.m 3 | // vvebo 4 | // 5 | // Created by Johnil on 14-3-6. 6 | // Copyright (c) 2014年 Johnil. All rights reserved. 7 | // 8 | 9 | #import "VVeboImageView.h" 10 | #import "VVeboImageTicker.h" 11 | @implementation VVeboImageView { 12 | VVeboImage *gifImage; 13 | } 14 | 15 | - (void)setImage:(UIImage *)image{ 16 | if (image==nil) { 17 | [super setImage:nil]; 18 | return; 19 | } 20 | if ([image isKindOfClass:[VVeboImage class]]) { 21 | gifImage = (VVeboImage *)image; 22 | if ([(VVeboImage *)image count]>1) { 23 | _frameDuration = [gifImage frameDuration]; 24 | [(VVeboImage *)image resumeIndex]; 25 | [super setImage:[(VVeboImage *)image nextImage]]; 26 | [[VVeboImageTicker sharedInstance] tickView:self]; 27 | } else { 28 | [super setImage:image]; 29 | } 30 | } else { 31 | [super setImage:image]; 32 | } 33 | } 34 | 35 | - (void)playNext{ 36 | if (_currentDuration<_frameDuration) { 37 | _currentDuration+=tickStep; 38 | return; 39 | } 40 | _frameDuration = [gifImage frameDuration]; 41 | [super setImage:[gifImage nextImage]]; 42 | _currentDuration = 0; 43 | } 44 | 45 | - (void)playGif{ 46 | [[VVeboImageTicker sharedInstance] tickView:self]; 47 | } 48 | 49 | - (void)pauseGif{ 50 | [[VVeboImageTicker sharedInstance] unTickView:self]; 51 | } 52 | 53 | - (void)removeFromSuperview{ 54 | [[VVeboImageTicker sharedInstance] unTickView:self]; 55 | self.image = nil; 56 | [super removeFromSuperview]; 57 | } 58 | 59 | - (void)dealloc{ 60 | NSLog(@"imageview dealloc"); 61 | } 62 | 63 | @end 64 | -------------------------------------------------------------------------------- /VVeboImageView/VVeboImageView/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // VVeboImageView 4 | // 5 | // Created by Johnil on 14-3-7. 6 | // Copyright (c) 2014年 Johnil. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /VVeboImageView/VVeboImageView/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // VVeboImageView 4 | // 5 | // Created by Johnil on 14-3-7. 6 | // Copyright (c) 2014年 Johnil. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | #import "VVeboImageView.h" 11 | @interface ViewController () 12 | 13 | @end 14 | 15 | @implementation ViewController { 16 | UIScrollView *scrollView; 17 | } 18 | 19 | - (void)viewDidLoad 20 | { 21 | [super viewDidLoad]; 22 | scrollView = [[UIScrollView alloc] initWithFrame:self.view.frame]; 23 | scrollView.contentSize = CGSizeMake(320*2, 0); 24 | scrollView.pagingEnabled = YES; 25 | scrollView.clipsToBounds = NO; 26 | scrollView.center = CGPointMake(scrollView.center.x+35, scrollView.center.y+10); 27 | [self.view addSubview:scrollView]; 28 | 29 | NSData *data = [NSData dataWithContentsOfFile: 30 | [[NSBundle mainBundle] pathForResource:@"1.gif" ofType:nil]]; 31 | for (int i=0; i<10; i++) { 32 | VVeboImageView *gif = [[VVeboImageView alloc] initWithImage:[VVeboImage gifWithData:data]]; 33 | gif.tag = 1; 34 | gif.frame = CGRectMake(i%2*130, i/2*100+20, 122, 89); 35 | [scrollView addSubview:gif]; 36 | } 37 | 38 | NSData *bigData = [NSData dataWithContentsOfFile: 39 | [[NSBundle mainBundle] pathForResource:@"2.gif" ofType:nil]]; 40 | VVeboImageView *gif = [[VVeboImageView alloc] initWithImage:[VVeboImage gifWithData:bigData]]; 41 | gif.tag = 1; 42 | CGRect frame = gif.frame; 43 | frame.origin.x = 320; 44 | gif.frame = frame; 45 | [scrollView addSubview:gif]; 46 | 47 | UILabel *description = [[UILabel alloc] initWithFrame:CGRectMake(0, gif.frame.size.height-60, 320, 50)]; 48 | description.text = @"这是十张1.4M的gif图"; 49 | [scrollView addSubview:description]; 50 | 51 | UILabel *description2 = [[UILabel alloc] initWithFrame:CGRectMake(0, gif.frame.size.height-60, 320, 50)]; 52 | description2.text = @"这是一张23.1M的gif图"; 53 | [gif addSubview:description2]; 54 | } 55 | 56 | - (void)didReceiveMemoryWarning 57 | { 58 | [super didReceiveMemoryWarning]; 59 | // Dispose of any resources that can be recreated. 60 | } 61 | 62 | @end 63 | -------------------------------------------------------------------------------- /VVeboImageView/VVeboImageView/en.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* Localized versions of Info.plist keys */ 2 | 3 | -------------------------------------------------------------------------------- /VVeboImageView/VVeboImageView/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // VVeboImageView 4 | // 5 | // Created by Johnil on 14-3-7. 6 | // Copyright (c) 2014年 Johnil. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | #import "AppDelegate.h" 12 | 13 | int main(int argc, char * argv[]) 14 | { 15 | @autoreleasepool { 16 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /VVeboImageView/VVeboImageViewTests/VVeboImageViewTests-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | com.johnil.${PRODUCT_NAME:rfc1034identifier} 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundlePackageType 14 | BNDL 15 | CFBundleShortVersionString 16 | 1.0 17 | CFBundleSignature 18 | ???? 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /VVeboImageView/VVeboImageViewTests/VVeboImageViewTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // VVeboImageViewTests.m 3 | // VVeboImageViewTests 4 | // 5 | // Created by Johnil on 14-3-7. 6 | // Copyright (c) 2014年 Johnil. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface VVeboImageViewTests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation VVeboImageViewTests 16 | 17 | - (void)setUp 18 | { 19 | [super setUp]; 20 | // Put setup code here. This method is called before the invocation of each test method in the class. 21 | } 22 | 23 | - (void)tearDown 24 | { 25 | // Put teardown code here. This method is called after the invocation of each test method in the class. 26 | [super tearDown]; 27 | } 28 | 29 | - (void)testExample 30 | { 31 | XCTFail(@"No implementation for \"%s\"", __PRETTY_FUNCTION__); 32 | } 33 | 34 | @end 35 | -------------------------------------------------------------------------------- /VVeboImageView/VVeboImageViewTests/en.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* Localized versions of Info.plist keys */ 2 | 3 | --------------------------------------------------------------------------------