├── .gitignore ├── Naughty.gif ├── NaughtyImageView.podspec ├── NaughtyImageView.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ │ ├── IDEWorkspaceChecks.plist │ │ └── NaughtyImageView.xccheckout └── xcuserdata │ ├── kevin.xcuserdatad │ └── xcschemes │ │ ├── NaughtyImageView.xcscheme │ │ └── xcschememanagement.plist │ ├── kevinzhow.xcuserdatad │ └── xcschemes │ │ ├── NaughtyImageView.xcscheme │ │ └── xcschememanagement.plist │ ├── zhoukaiwen.xcuserdatad │ └── xcschemes │ │ └── xcschememanagement.plist │ └── zhowkevin.xcuserdatad │ └── xcschemes │ ├── NaughtyImageView.xcscheme │ └── xcschememanagement.plist ├── NaughtyImageView ├── AppDelegate.swift ├── Base.lproj │ ├── LaunchScreen.xib │ └── Main.storyboard ├── Images.xcassets │ ├── AppIcon.appiconset │ │ └── Contents.json │ ├── fav.imageset │ │ ├── Contents.json │ │ └── fav.png │ ├── pull.imageset │ │ ├── Contents.json │ │ └── pull.png │ └── star.imageset │ │ ├── Contents.json │ │ └── NEXT-moon-60fps.png ├── Info.plist ├── Source │ └── NaughtyImageView.swift └── ViewController.swift ├── NaughtyImageViewTests ├── Info.plist └── NaughtyImageViewTests.swift └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | Build 2 | RichTextView.xcodeproj/project.xcworkspace/xcuserdata/kevin.xcuserdatad/UserInterfaceState.xcuserstate 3 | .DS_Store 4 | UserInterfaceState.xcuserstate 5 | -------------------------------------------------------------------------------- /Naughty.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kevinzhow/NaughtyImageView/b04231edf70f721bcae9d1c92946a228b9f9721b/Naughty.gif -------------------------------------------------------------------------------- /NaughtyImageView.podspec: -------------------------------------------------------------------------------- 1 | Pod::Spec.new do |s| 2 | 3 | s.name = "NaughtyImageView" 4 | s.version = "0.2.6" 5 | s.summary = "UIImageView Can Animate Sprite Image" 6 | 7 | s.description = <<-DESC 8 | UIImageView Can Animate Sprite Image with Progress control. 9 | DESC 10 | 11 | s.homepage = "https://github.com/kevinzhow/NaughtyImageView" 12 | s.screenshots = "https://raw.githubusercontent.com/onevcat/Kingfisher/master/images/logo.png" 13 | 14 | s.license = { :type => "MIT", :file => "LICENSE" } 15 | 16 | s.authors = { "kevinzhow" => "kevinchou.c@gmail.com" } 17 | s.social_media_url = "http://twitter.com/kevinzhow" 18 | 19 | s.ios.deployment_target = "8.0" 20 | # s.osx.deployment_target = "10.7" 21 | 22 | s.source = { :git => "https://github.com/kevinzhow/NaughtyImageView.git", :tag => s.version } 23 | s.source_files = "NaughtyImageView/Source/*.swift" 24 | s.requires_arc = true 25 | 26 | end 27 | -------------------------------------------------------------------------------- /NaughtyImageView.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 0A036EDD1B531C1500F03503 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A036EDC1B531C1500F03503 /* AppDelegate.swift */; }; 11 | 0A036EDF1B531C1500F03503 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A036EDE1B531C1500F03503 /* ViewController.swift */; }; 12 | 0A036EE21B531C1500F03503 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 0A036EE01B531C1500F03503 /* Main.storyboard */; }; 13 | 0A036EE41B531C1500F03503 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 0A036EE31B531C1500F03503 /* Images.xcassets */; }; 14 | 0A036EE71B531C1500F03503 /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 0A036EE51B531C1500F03503 /* LaunchScreen.xib */; }; 15 | 0A036EF31B531C1500F03503 /* NaughtyImageViewTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A036EF21B531C1500F03503 /* NaughtyImageViewTests.swift */; }; 16 | 0A036EFD1B531DF600F03503 /* NaughtyImageView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A036EFC1B531DF600F03503 /* NaughtyImageView.swift */; }; 17 | /* End PBXBuildFile section */ 18 | 19 | /* Begin PBXContainerItemProxy section */ 20 | 0A036EED1B531C1500F03503 /* PBXContainerItemProxy */ = { 21 | isa = PBXContainerItemProxy; 22 | containerPortal = 0A036ECF1B531C1500F03503 /* Project object */; 23 | proxyType = 1; 24 | remoteGlobalIDString = 0A036ED61B531C1500F03503; 25 | remoteInfo = NaughtyImageView; 26 | }; 27 | /* End PBXContainerItemProxy section */ 28 | 29 | /* Begin PBXFileReference section */ 30 | 0A036ED71B531C1500F03503 /* NaughtyImageView.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = NaughtyImageView.app; sourceTree = BUILT_PRODUCTS_DIR; }; 31 | 0A036EDB1B531C1500F03503 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 32 | 0A036EDC1B531C1500F03503 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 33 | 0A036EDE1B531C1500F03503 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; 34 | 0A036EE11B531C1500F03503 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 35 | 0A036EE31B531C1500F03503 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; 36 | 0A036EE61B531C1500F03503 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/LaunchScreen.xib; sourceTree = ""; }; 37 | 0A036EEC1B531C1500F03503 /* NaughtyImageViewTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = NaughtyImageViewTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 38 | 0A036EF11B531C1500F03503 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 39 | 0A036EF21B531C1500F03503 /* NaughtyImageViewTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NaughtyImageViewTests.swift; sourceTree = ""; }; 40 | 0A036EFC1B531DF600F03503 /* NaughtyImageView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = NaughtyImageView.swift; path = Source/NaughtyImageView.swift; sourceTree = ""; }; 41 | /* End PBXFileReference section */ 42 | 43 | /* Begin PBXFrameworksBuildPhase section */ 44 | 0A036ED41B531C1500F03503 /* Frameworks */ = { 45 | isa = PBXFrameworksBuildPhase; 46 | buildActionMask = 2147483647; 47 | files = ( 48 | ); 49 | runOnlyForDeploymentPostprocessing = 0; 50 | }; 51 | 0A036EE91B531C1500F03503 /* Frameworks */ = { 52 | isa = PBXFrameworksBuildPhase; 53 | buildActionMask = 2147483647; 54 | files = ( 55 | ); 56 | runOnlyForDeploymentPostprocessing = 0; 57 | }; 58 | /* End PBXFrameworksBuildPhase section */ 59 | 60 | /* Begin PBXGroup section */ 61 | 0A036ECE1B531C1500F03503 = { 62 | isa = PBXGroup; 63 | children = ( 64 | 0A036ED91B531C1500F03503 /* NaughtyImageView */, 65 | 0A036EEF1B531C1500F03503 /* NaughtyImageViewTests */, 66 | 0A036ED81B531C1500F03503 /* Products */, 67 | ); 68 | sourceTree = ""; 69 | }; 70 | 0A036ED81B531C1500F03503 /* Products */ = { 71 | isa = PBXGroup; 72 | children = ( 73 | 0A036ED71B531C1500F03503 /* NaughtyImageView.app */, 74 | 0A036EEC1B531C1500F03503 /* NaughtyImageViewTests.xctest */, 75 | ); 76 | name = Products; 77 | sourceTree = ""; 78 | }; 79 | 0A036ED91B531C1500F03503 /* NaughtyImageView */ = { 80 | isa = PBXGroup; 81 | children = ( 82 | 0A036EFC1B531DF600F03503 /* NaughtyImageView.swift */, 83 | 0A036EDC1B531C1500F03503 /* AppDelegate.swift */, 84 | 0A036EDE1B531C1500F03503 /* ViewController.swift */, 85 | 0A036EE01B531C1500F03503 /* Main.storyboard */, 86 | 0A036EE31B531C1500F03503 /* Images.xcassets */, 87 | 0A036EE51B531C1500F03503 /* LaunchScreen.xib */, 88 | 0A036EDA1B531C1500F03503 /* Supporting Files */, 89 | ); 90 | path = NaughtyImageView; 91 | sourceTree = ""; 92 | }; 93 | 0A036EDA1B531C1500F03503 /* Supporting Files */ = { 94 | isa = PBXGroup; 95 | children = ( 96 | 0A036EDB1B531C1500F03503 /* Info.plist */, 97 | ); 98 | name = "Supporting Files"; 99 | sourceTree = ""; 100 | }; 101 | 0A036EEF1B531C1500F03503 /* NaughtyImageViewTests */ = { 102 | isa = PBXGroup; 103 | children = ( 104 | 0A036EF21B531C1500F03503 /* NaughtyImageViewTests.swift */, 105 | 0A036EF01B531C1500F03503 /* Supporting Files */, 106 | ); 107 | path = NaughtyImageViewTests; 108 | sourceTree = ""; 109 | }; 110 | 0A036EF01B531C1500F03503 /* Supporting Files */ = { 111 | isa = PBXGroup; 112 | children = ( 113 | 0A036EF11B531C1500F03503 /* Info.plist */, 114 | ); 115 | name = "Supporting Files"; 116 | sourceTree = ""; 117 | }; 118 | /* End PBXGroup section */ 119 | 120 | /* Begin PBXNativeTarget section */ 121 | 0A036ED61B531C1500F03503 /* NaughtyImageView */ = { 122 | isa = PBXNativeTarget; 123 | buildConfigurationList = 0A036EF61B531C1500F03503 /* Build configuration list for PBXNativeTarget "NaughtyImageView" */; 124 | buildPhases = ( 125 | 0A036ED31B531C1500F03503 /* Sources */, 126 | 0A036ED41B531C1500F03503 /* Frameworks */, 127 | 0A036ED51B531C1500F03503 /* Resources */, 128 | ); 129 | buildRules = ( 130 | ); 131 | dependencies = ( 132 | ); 133 | name = NaughtyImageView; 134 | productName = NaughtyImageView; 135 | productReference = 0A036ED71B531C1500F03503 /* NaughtyImageView.app */; 136 | productType = "com.apple.product-type.application"; 137 | }; 138 | 0A036EEB1B531C1500F03503 /* NaughtyImageViewTests */ = { 139 | isa = PBXNativeTarget; 140 | buildConfigurationList = 0A036EF91B531C1500F03503 /* Build configuration list for PBXNativeTarget "NaughtyImageViewTests" */; 141 | buildPhases = ( 142 | 0A036EE81B531C1500F03503 /* Sources */, 143 | 0A036EE91B531C1500F03503 /* Frameworks */, 144 | 0A036EEA1B531C1500F03503 /* Resources */, 145 | ); 146 | buildRules = ( 147 | ); 148 | dependencies = ( 149 | 0A036EEE1B531C1500F03503 /* PBXTargetDependency */, 150 | ); 151 | name = NaughtyImageViewTests; 152 | productName = NaughtyImageViewTests; 153 | productReference = 0A036EEC1B531C1500F03503 /* NaughtyImageViewTests.xctest */; 154 | productType = "com.apple.product-type.bundle.unit-test"; 155 | }; 156 | /* End PBXNativeTarget section */ 157 | 158 | /* Begin PBXProject section */ 159 | 0A036ECF1B531C1500F03503 /* Project object */ = { 160 | isa = PBXProject; 161 | attributes = { 162 | LastSwiftMigration = 0700; 163 | LastSwiftUpdateCheck = 0700; 164 | LastUpgradeCheck = 0800; 165 | ORGANIZATIONNAME = kevinzhow; 166 | TargetAttributes = { 167 | 0A036ED61B531C1500F03503 = { 168 | CreatedOnToolsVersion = 6.4; 169 | LastSwiftMigration = 0800; 170 | }; 171 | 0A036EEB1B531C1500F03503 = { 172 | CreatedOnToolsVersion = 6.4; 173 | LastSwiftMigration = 0800; 174 | TestTargetID = 0A036ED61B531C1500F03503; 175 | }; 176 | }; 177 | }; 178 | buildConfigurationList = 0A036ED21B531C1500F03503 /* Build configuration list for PBXProject "NaughtyImageView" */; 179 | compatibilityVersion = "Xcode 3.2"; 180 | developmentRegion = English; 181 | hasScannedForEncodings = 0; 182 | knownRegions = ( 183 | en, 184 | Base, 185 | ); 186 | mainGroup = 0A036ECE1B531C1500F03503; 187 | productRefGroup = 0A036ED81B531C1500F03503 /* Products */; 188 | projectDirPath = ""; 189 | projectRoot = ""; 190 | targets = ( 191 | 0A036ED61B531C1500F03503 /* NaughtyImageView */, 192 | 0A036EEB1B531C1500F03503 /* NaughtyImageViewTests */, 193 | ); 194 | }; 195 | /* End PBXProject section */ 196 | 197 | /* Begin PBXResourcesBuildPhase section */ 198 | 0A036ED51B531C1500F03503 /* Resources */ = { 199 | isa = PBXResourcesBuildPhase; 200 | buildActionMask = 2147483647; 201 | files = ( 202 | 0A036EE21B531C1500F03503 /* Main.storyboard in Resources */, 203 | 0A036EE71B531C1500F03503 /* LaunchScreen.xib in Resources */, 204 | 0A036EE41B531C1500F03503 /* Images.xcassets in Resources */, 205 | ); 206 | runOnlyForDeploymentPostprocessing = 0; 207 | }; 208 | 0A036EEA1B531C1500F03503 /* Resources */ = { 209 | isa = PBXResourcesBuildPhase; 210 | buildActionMask = 2147483647; 211 | files = ( 212 | ); 213 | runOnlyForDeploymentPostprocessing = 0; 214 | }; 215 | /* End PBXResourcesBuildPhase section */ 216 | 217 | /* Begin PBXSourcesBuildPhase section */ 218 | 0A036ED31B531C1500F03503 /* Sources */ = { 219 | isa = PBXSourcesBuildPhase; 220 | buildActionMask = 2147483647; 221 | files = ( 222 | 0A036EDF1B531C1500F03503 /* ViewController.swift in Sources */, 223 | 0A036EFD1B531DF600F03503 /* NaughtyImageView.swift in Sources */, 224 | 0A036EDD1B531C1500F03503 /* AppDelegate.swift in Sources */, 225 | ); 226 | runOnlyForDeploymentPostprocessing = 0; 227 | }; 228 | 0A036EE81B531C1500F03503 /* Sources */ = { 229 | isa = PBXSourcesBuildPhase; 230 | buildActionMask = 2147483647; 231 | files = ( 232 | 0A036EF31B531C1500F03503 /* NaughtyImageViewTests.swift in Sources */, 233 | ); 234 | runOnlyForDeploymentPostprocessing = 0; 235 | }; 236 | /* End PBXSourcesBuildPhase section */ 237 | 238 | /* Begin PBXTargetDependency section */ 239 | 0A036EEE1B531C1500F03503 /* PBXTargetDependency */ = { 240 | isa = PBXTargetDependency; 241 | target = 0A036ED61B531C1500F03503 /* NaughtyImageView */; 242 | targetProxy = 0A036EED1B531C1500F03503 /* PBXContainerItemProxy */; 243 | }; 244 | /* End PBXTargetDependency section */ 245 | 246 | /* Begin PBXVariantGroup section */ 247 | 0A036EE01B531C1500F03503 /* Main.storyboard */ = { 248 | isa = PBXVariantGroup; 249 | children = ( 250 | 0A036EE11B531C1500F03503 /* Base */, 251 | ); 252 | name = Main.storyboard; 253 | sourceTree = ""; 254 | }; 255 | 0A036EE51B531C1500F03503 /* LaunchScreen.xib */ = { 256 | isa = PBXVariantGroup; 257 | children = ( 258 | 0A036EE61B531C1500F03503 /* Base */, 259 | ); 260 | name = LaunchScreen.xib; 261 | sourceTree = ""; 262 | }; 263 | /* End PBXVariantGroup section */ 264 | 265 | /* Begin XCBuildConfiguration section */ 266 | 0A036EF41B531C1500F03503 /* Debug */ = { 267 | isa = XCBuildConfiguration; 268 | buildSettings = { 269 | ALWAYS_SEARCH_USER_PATHS = NO; 270 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 271 | CLANG_CXX_LIBRARY = "libc++"; 272 | CLANG_ENABLE_MODULES = YES; 273 | CLANG_ENABLE_OBJC_ARC = YES; 274 | CLANG_WARN_BOOL_CONVERSION = YES; 275 | CLANG_WARN_CONSTANT_CONVERSION = YES; 276 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 277 | CLANG_WARN_EMPTY_BODY = YES; 278 | CLANG_WARN_ENUM_CONVERSION = YES; 279 | CLANG_WARN_INFINITE_RECURSION = YES; 280 | CLANG_WARN_INT_CONVERSION = YES; 281 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 282 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 283 | CLANG_WARN_UNREACHABLE_CODE = YES; 284 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 285 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 286 | COPY_PHASE_STRIP = NO; 287 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 288 | ENABLE_STRICT_OBJC_MSGSEND = YES; 289 | ENABLE_TESTABILITY = YES; 290 | GCC_C_LANGUAGE_STANDARD = gnu99; 291 | GCC_DYNAMIC_NO_PIC = NO; 292 | GCC_NO_COMMON_BLOCKS = YES; 293 | GCC_OPTIMIZATION_LEVEL = 0; 294 | GCC_PREPROCESSOR_DEFINITIONS = ( 295 | "DEBUG=1", 296 | "$(inherited)", 297 | ); 298 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 299 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 300 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 301 | GCC_WARN_UNDECLARED_SELECTOR = YES; 302 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 303 | GCC_WARN_UNUSED_FUNCTION = YES; 304 | GCC_WARN_UNUSED_VARIABLE = YES; 305 | IPHONEOS_DEPLOYMENT_TARGET = 8.4; 306 | MTL_ENABLE_DEBUG_INFO = YES; 307 | ONLY_ACTIVE_ARCH = YES; 308 | SDKROOT = iphoneos; 309 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 310 | }; 311 | name = Debug; 312 | }; 313 | 0A036EF51B531C1500F03503 /* Release */ = { 314 | isa = XCBuildConfiguration; 315 | buildSettings = { 316 | ALWAYS_SEARCH_USER_PATHS = NO; 317 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 318 | CLANG_CXX_LIBRARY = "libc++"; 319 | CLANG_ENABLE_MODULES = YES; 320 | CLANG_ENABLE_OBJC_ARC = YES; 321 | CLANG_WARN_BOOL_CONVERSION = YES; 322 | CLANG_WARN_CONSTANT_CONVERSION = YES; 323 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 324 | CLANG_WARN_EMPTY_BODY = YES; 325 | CLANG_WARN_ENUM_CONVERSION = YES; 326 | CLANG_WARN_INFINITE_RECURSION = YES; 327 | CLANG_WARN_INT_CONVERSION = YES; 328 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 329 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 330 | CLANG_WARN_UNREACHABLE_CODE = YES; 331 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 332 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 333 | COPY_PHASE_STRIP = NO; 334 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 335 | ENABLE_NS_ASSERTIONS = NO; 336 | ENABLE_STRICT_OBJC_MSGSEND = YES; 337 | GCC_C_LANGUAGE_STANDARD = gnu99; 338 | GCC_NO_COMMON_BLOCKS = YES; 339 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 340 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 341 | GCC_WARN_UNDECLARED_SELECTOR = YES; 342 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 343 | GCC_WARN_UNUSED_FUNCTION = YES; 344 | GCC_WARN_UNUSED_VARIABLE = YES; 345 | IPHONEOS_DEPLOYMENT_TARGET = 8.4; 346 | MTL_ENABLE_DEBUG_INFO = NO; 347 | SDKROOT = iphoneos; 348 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; 349 | VALIDATE_PRODUCT = YES; 350 | }; 351 | name = Release; 352 | }; 353 | 0A036EF71B531C1500F03503 /* Debug */ = { 354 | isa = XCBuildConfiguration; 355 | buildSettings = { 356 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 357 | INFOPLIST_FILE = NaughtyImageView/Info.plist; 358 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 359 | PRODUCT_BUNDLE_IDENTIFIER = "kevinzhow.$(PRODUCT_NAME:rfc1034identifier)"; 360 | PRODUCT_NAME = "$(TARGET_NAME)"; 361 | SWIFT_VERSION = 4.2; 362 | }; 363 | name = Debug; 364 | }; 365 | 0A036EF81B531C1500F03503 /* Release */ = { 366 | isa = XCBuildConfiguration; 367 | buildSettings = { 368 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 369 | INFOPLIST_FILE = NaughtyImageView/Info.plist; 370 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 371 | PRODUCT_BUNDLE_IDENTIFIER = "kevinzhow.$(PRODUCT_NAME:rfc1034identifier)"; 372 | PRODUCT_NAME = "$(TARGET_NAME)"; 373 | SWIFT_VERSION = 4.2; 374 | }; 375 | name = Release; 376 | }; 377 | 0A036EFA1B531C1500F03503 /* Debug */ = { 378 | isa = XCBuildConfiguration; 379 | buildSettings = { 380 | BUNDLE_LOADER = "$(TEST_HOST)"; 381 | FRAMEWORK_SEARCH_PATHS = ( 382 | "$(SDKROOT)/Developer/Library/Frameworks", 383 | "$(inherited)", 384 | ); 385 | GCC_PREPROCESSOR_DEFINITIONS = ( 386 | "DEBUG=1", 387 | "$(inherited)", 388 | ); 389 | INFOPLIST_FILE = NaughtyImageViewTests/Info.plist; 390 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 391 | PRODUCT_BUNDLE_IDENTIFIER = "kevinzhow.$(PRODUCT_NAME:rfc1034identifier)"; 392 | PRODUCT_NAME = "$(TARGET_NAME)"; 393 | SWIFT_VERSION = 3.0; 394 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/NaughtyImageView.app/NaughtyImageView"; 395 | }; 396 | name = Debug; 397 | }; 398 | 0A036EFB1B531C1500F03503 /* Release */ = { 399 | isa = XCBuildConfiguration; 400 | buildSettings = { 401 | BUNDLE_LOADER = "$(TEST_HOST)"; 402 | FRAMEWORK_SEARCH_PATHS = ( 403 | "$(SDKROOT)/Developer/Library/Frameworks", 404 | "$(inherited)", 405 | ); 406 | INFOPLIST_FILE = NaughtyImageViewTests/Info.plist; 407 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 408 | PRODUCT_BUNDLE_IDENTIFIER = "kevinzhow.$(PRODUCT_NAME:rfc1034identifier)"; 409 | PRODUCT_NAME = "$(TARGET_NAME)"; 410 | SWIFT_VERSION = 3.0; 411 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/NaughtyImageView.app/NaughtyImageView"; 412 | }; 413 | name = Release; 414 | }; 415 | /* End XCBuildConfiguration section */ 416 | 417 | /* Begin XCConfigurationList section */ 418 | 0A036ED21B531C1500F03503 /* Build configuration list for PBXProject "NaughtyImageView" */ = { 419 | isa = XCConfigurationList; 420 | buildConfigurations = ( 421 | 0A036EF41B531C1500F03503 /* Debug */, 422 | 0A036EF51B531C1500F03503 /* Release */, 423 | ); 424 | defaultConfigurationIsVisible = 0; 425 | defaultConfigurationName = Release; 426 | }; 427 | 0A036EF61B531C1500F03503 /* Build configuration list for PBXNativeTarget "NaughtyImageView" */ = { 428 | isa = XCConfigurationList; 429 | buildConfigurations = ( 430 | 0A036EF71B531C1500F03503 /* Debug */, 431 | 0A036EF81B531C1500F03503 /* Release */, 432 | ); 433 | defaultConfigurationIsVisible = 0; 434 | defaultConfigurationName = Release; 435 | }; 436 | 0A036EF91B531C1500F03503 /* Build configuration list for PBXNativeTarget "NaughtyImageViewTests" */ = { 437 | isa = XCConfigurationList; 438 | buildConfigurations = ( 439 | 0A036EFA1B531C1500F03503 /* Debug */, 440 | 0A036EFB1B531C1500F03503 /* Release */, 441 | ); 442 | defaultConfigurationIsVisible = 0; 443 | defaultConfigurationName = Release; 444 | }; 445 | /* End XCConfigurationList section */ 446 | }; 447 | rootObject = 0A036ECF1B531C1500F03503 /* Project object */; 448 | } 449 | -------------------------------------------------------------------------------- /NaughtyImageView.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /NaughtyImageView.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /NaughtyImageView.xcodeproj/project.xcworkspace/xcshareddata/NaughtyImageView.xccheckout: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDESourceControlProjectFavoriteDictionaryKey 6 | 7 | IDESourceControlProjectIdentifier 8 | 9A76F8CC-1199-44DA-8C50-4EA2976D0833 9 | IDESourceControlProjectName 10 | NaughtyImageView 11 | IDESourceControlProjectOriginsDictionary 12 | 13 | 66A3868364B0266C1D2ABE04FB26E655E5F69297 14 | github.com:kevinzhow/NaughtyImageView.git 15 | 16 | IDESourceControlProjectPath 17 | NaughtyImageView.xcodeproj 18 | IDESourceControlProjectRelativeInstallPathDictionary 19 | 20 | 66A3868364B0266C1D2ABE04FB26E655E5F69297 21 | ../.. 22 | 23 | IDESourceControlProjectURL 24 | github.com:kevinzhow/NaughtyImageView.git 25 | IDESourceControlProjectVersion 26 | 111 27 | IDESourceControlProjectWCCIdentifier 28 | 66A3868364B0266C1D2ABE04FB26E655E5F69297 29 | IDESourceControlProjectWCConfigurations 30 | 31 | 32 | IDESourceControlRepositoryExtensionIdentifierKey 33 | public.vcs.git 34 | IDESourceControlWCCIdentifierKey 35 | 66A3868364B0266C1D2ABE04FB26E655E5F69297 36 | IDESourceControlWCCName 37 | NaughtyImageView 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /NaughtyImageView.xcodeproj/xcuserdata/kevin.xcuserdatad/xcschemes/NaughtyImageView.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 29 | 35 | 36 | 37 | 38 | 39 | 44 | 45 | 47 | 53 | 54 | 55 | 56 | 57 | 63 | 64 | 65 | 66 | 75 | 77 | 83 | 84 | 85 | 86 | 87 | 88 | 94 | 96 | 102 | 103 | 104 | 105 | 107 | 108 | 111 | 112 | 113 | -------------------------------------------------------------------------------- /NaughtyImageView.xcodeproj/xcuserdata/kevin.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | NaughtyImageView.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | 0A036ED61B531C1500F03503 16 | 17 | primary 18 | 19 | 20 | 0A036EEB1B531C1500F03503 21 | 22 | primary 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /NaughtyImageView.xcodeproj/xcuserdata/kevinzhow.xcuserdatad/xcschemes/NaughtyImageView.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 33 | 39 | 40 | 41 | 42 | 43 | 49 | 50 | 51 | 52 | 53 | 54 | 64 | 66 | 72 | 73 | 74 | 75 | 76 | 77 | 83 | 85 | 91 | 92 | 93 | 94 | 96 | 97 | 100 | 101 | 102 | -------------------------------------------------------------------------------- /NaughtyImageView.xcodeproj/xcuserdata/kevinzhow.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | NaughtyImageView.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | 0A036ED61B531C1500F03503 16 | 17 | primary 18 | 19 | 20 | 0A036EEB1B531C1500F03503 21 | 22 | primary 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /NaughtyImageView.xcodeproj/xcuserdata/zhoukaiwen.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | NaughtyImageView.xcscheme_^#shared#^_ 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /NaughtyImageView.xcodeproj/xcuserdata/zhowkevin.xcuserdatad/xcschemes/NaughtyImageView.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 33 | 39 | 40 | 41 | 42 | 43 | 49 | 50 | 51 | 52 | 53 | 54 | 64 | 66 | 72 | 73 | 74 | 75 | 76 | 77 | 83 | 85 | 91 | 92 | 93 | 94 | 96 | 97 | 100 | 101 | 102 | -------------------------------------------------------------------------------- /NaughtyImageView.xcodeproj/xcuserdata/zhowkevin.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | NaughtyImageView.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | 0A036ED61B531C1500F03503 16 | 17 | primary 18 | 19 | 20 | 0A036EEB1B531C1500F03503 21 | 22 | primary 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /NaughtyImageView/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // NaughtyImageView 4 | // 5 | // Created by kevinzhow on 15/7/13. 6 | // Copyright (c) 2015年 kevinzhow. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @UIApplicationMain 12 | class AppDelegate: UIResponder, UIApplicationDelegate { 13 | 14 | var window: UIWindow? 15 | 16 | 17 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { 18 | // Override point for customization after application launch. 19 | return true 20 | } 21 | 22 | func applicationWillResignActive(_ application: UIApplication) { 23 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 24 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. 25 | } 26 | 27 | func applicationDidEnterBackground(_ application: UIApplication) { 28 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 29 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 30 | } 31 | 32 | func applicationWillEnterForeground(_ application: UIApplication) { 33 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. 34 | } 35 | 36 | func applicationDidBecomeActive(_ application: UIApplication) { 37 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 38 | } 39 | 40 | func applicationWillTerminate(_ application: UIApplication) { 41 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 42 | } 43 | 44 | 45 | } 46 | 47 | -------------------------------------------------------------------------------- /NaughtyImageView/Base.lproj/LaunchScreen.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 20 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /NaughtyImageView/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 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | -------------------------------------------------------------------------------- /NaughtyImageView/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" : "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 | } -------------------------------------------------------------------------------- /NaughtyImageView/Images.xcassets/fav.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "scale" : "2x", 10 | "filename" : "fav.png" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /NaughtyImageView/Images.xcassets/fav.imageset/fav.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kevinzhow/NaughtyImageView/b04231edf70f721bcae9d1c92946a228b9f9721b/NaughtyImageView/Images.xcassets/fav.imageset/fav.png -------------------------------------------------------------------------------- /NaughtyImageView/Images.xcassets/pull.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "scale" : "2x", 10 | "filename" : "pull.png" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /NaughtyImageView/Images.xcassets/pull.imageset/pull.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kevinzhow/NaughtyImageView/b04231edf70f721bcae9d1c92946a228b9f9721b/NaughtyImageView/Images.xcassets/pull.imageset/pull.png -------------------------------------------------------------------------------- /NaughtyImageView/Images.xcassets/star.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "scale" : "2x", 10 | "filename" : "NEXT-moon-60fps.png" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /NaughtyImageView/Images.xcassets/star.imageset/NEXT-moon-60fps.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kevinzhow/NaughtyImageView/b04231edf70f721bcae9d1c92946a228b9f9721b/NaughtyImageView/Images.xcassets/star.imageset/NEXT-moon-60fps.png -------------------------------------------------------------------------------- /NaughtyImageView/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 | 40 | 41 | -------------------------------------------------------------------------------- /NaughtyImageView/Source/NaughtyImageView.swift: -------------------------------------------------------------------------------- 1 | // 2 | // NaughtyImageView.swift 3 | // 4 | // 5 | // Created by kevinzhow on 15/7/13. 6 | // 7 | // 8 | 9 | import UIKit 10 | 11 | open class NaughtyImageView: UIImageView { 12 | 13 | open var horizontalImages: Int! 14 | 15 | open var verticalImages: Int! 16 | 17 | var floatingImage: UIImageView! 18 | 19 | var positionMatrix = [CGPoint(x: 0, y: 0)] 20 | 21 | open var currentIndex = 0 { 22 | didSet { 23 | 24 | let location = locateFrame(currentIndex) 25 | 26 | floatingImage.frame = CGRect(x: -location.x * frame.width, y: -location.y * frame.height, width: floatingImage.frame.width, height: floatingImage.frame.height) 27 | } 28 | } 29 | 30 | var displayLink: CADisplayLink! 31 | 32 | open var naughtyAnimating = false 33 | 34 | open var frameSkip = 0 35 | 36 | fileprivate var frameCount = 0 37 | 38 | open var loop = true 39 | 40 | fileprivate var finished = false 41 | 42 | open var naughtyAnimationDidStop: ((Bool) -> Void)? 43 | 44 | open var debug = false { 45 | didSet { 46 | if debug { 47 | clipsToBounds = false 48 | layer.borderColor = UIColor.red.cgColor 49 | layer.borderWidth = 1.0 50 | } else { 51 | clipsToBounds = true 52 | } 53 | } 54 | } 55 | 56 | override public init(frame: CGRect) { 57 | super.init(frame: frame) 58 | initFloatingImageView() 59 | } 60 | 61 | required public init?(coder aDecoder: NSCoder) { 62 | super.init(coder: aDecoder) 63 | initFloatingImageView() 64 | } 65 | 66 | func initFloatingImageView() { 67 | floatingImage = UIImageView(frame: CGRect.zero) 68 | addSubview(floatingImage) 69 | } 70 | 71 | open func setupWithImage(_ newImage: UIImage, horizontalImages: Int, verticalImages: Int) { 72 | 73 | if !debug { 74 | clipsToBounds = true 75 | } 76 | 77 | floatingImage.frame = CGRect(x: 0, y: 0, width: frame.width * CGFloat(horizontalImages), height: frame.height * CGFloat(verticalImages)) 78 | 79 | floatingImage.image = newImage 80 | 81 | self.horizontalImages = horizontalImages 82 | self.verticalImages = verticalImages 83 | 84 | floatingImage.contentMode = .topLeft 85 | 86 | var index = 1 87 | 88 | var tempX = 1 89 | 90 | var tempY = 0 91 | 92 | while index <= (horizontalImages * verticalImages - 1) { 93 | 94 | positionMatrix.append(CGPoint(x: tempX, y: tempY)) 95 | 96 | if tempX + 1 > horizontalImages - 1 { 97 | tempX = 0 98 | tempY += 1 99 | } else { 100 | tempX += 1 101 | } 102 | 103 | index += 1 104 | } 105 | 106 | #if DEBUG 107 | println("\(horizontalImages) \(verticalImages)") 108 | println(positionMatrix) 109 | #endif 110 | 111 | } 112 | 113 | func locateFrame(_ frameIndex: Int) -> CGPoint { 114 | 115 | let location: CGPoint = positionMatrix[frameIndex] 116 | 117 | return location 118 | } 119 | 120 | open func toNewFrame(_ frameIndex: Int) { 121 | 122 | if frameIndex + 1 <= positionMatrix.count { 123 | currentIndex = frameIndex 124 | } else { 125 | if loop { 126 | currentIndex = 0 127 | } else { 128 | finished = true 129 | stopNaughtyAnimation() 130 | } 131 | 132 | } 133 | } 134 | 135 | open func startNaughtyAnimation() { 136 | finished = false 137 | naughtyAnimating = true 138 | displayLink = CADisplayLink(target: self, selector: #selector(NaughtyImageView.callbackNaughtyAnimation)) 139 | displayLink.add(to: .current, forMode: .common) 140 | } 141 | 142 | @objc open func callbackNaughtyAnimation() { 143 | 144 | if frameCount == frameSkip { 145 | toNewFrame(currentIndex + 1) 146 | frameCount = 0 147 | } else { 148 | frameCount += 1 149 | } 150 | 151 | } 152 | 153 | open func stopNaughtyAnimation() { 154 | naughtyAnimating = false 155 | displayLink.invalidate() 156 | 157 | if let naughtyAnimationDidStop = naughtyAnimationDidStop { 158 | naughtyAnimationDidStop(finished) 159 | } 160 | 161 | } 162 | } 163 | -------------------------------------------------------------------------------- /NaughtyImageView/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // NaughtyImageView 4 | // 5 | // Created by kevinzhow on 15/7/13. 6 | // Copyright (c) 2015年 kevinzhow. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class ViewController: UIViewController { 12 | 13 | @IBOutlet weak var slider: UISlider! 14 | 15 | var starImageView = NaughtyImageView(frame: CGRect.zero) 16 | 17 | override func viewDidLoad() { 18 | super.viewDidLoad() 19 | 20 | starImageView.frame = CGRect(x: view.frame.width/2.0 - 32/2.0, y: 100, width: 32, height: 32) 21 | 22 | starImageView.debug = false 23 | 24 | view.addSubview(starImageView) 25 | 26 | starImageView.setupWithImage(UIImage(named: "fav")!, horizontalImages: 8, verticalImages: 12) 27 | 28 | slider.maximumValue = Float(starImageView.horizontalImages * starImageView.verticalImages) - 1 29 | 30 | slider.value = 0 31 | 32 | slider.isContinuous = true 33 | 34 | slider.addTarget(self, action: #selector(ViewController.valueChanged(_:)), for: UIControl.Event.valueChanged) 35 | // Do any additional setup after loading the view, typically from a nib. 36 | } 37 | 38 | override func didReceiveMemoryWarning() { 39 | super.didReceiveMemoryWarning() 40 | // Dispose of any resources that can be recreated. 41 | } 42 | 43 | @objc func valueChanged(_ slider: UISlider) { 44 | 45 | let frameIndex = Int(slider.value) 46 | 47 | starImageView.toNewFrame(frameIndex) 48 | 49 | 50 | } 51 | 52 | @IBAction func start(_ sender: AnyObject) { 53 | if starImageView.naughtyAnimating { 54 | starImageView.stopNaughtyAnimation() 55 | } else { 56 | starImageView.startNaughtyAnimation() 57 | } 58 | 59 | } 60 | 61 | } 62 | 63 | -------------------------------------------------------------------------------- /NaughtyImageViewTests/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 | -------------------------------------------------------------------------------- /NaughtyImageViewTests/NaughtyImageViewTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // NaughtyImageViewTests.swift 3 | // NaughtyImageViewTests 4 | // 5 | // Created by kevinzhow on 15/7/13. 6 | // Copyright (c) 2015年 kevinzhow. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import XCTest 11 | 12 | class NaughtyImageViewTests: XCTestCase { 13 | 14 | override func setUp() { 15 | super.setUp() 16 | // Put setup code here. This method is called before the invocation of each test method in the class. 17 | } 18 | 19 | override func tearDown() { 20 | // Put teardown code here. This method is called after the invocation of each test method in the class. 21 | super.tearDown() 22 | } 23 | 24 | func testExample() { 25 | // This is an example of a functional test case. 26 | XCTAssert(true, "Pass") 27 | } 28 | 29 | func testPerformanceExample() { 30 | // This is an example of a performance test case. 31 | self.measure() { 32 | // Put the code you want to measure the time of here. 33 | } 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # NaughtyImageView 2 | UIImageView Can Animate Sprite Image Like Twitter Fav action 3 | 4 | ![NaughtyImageView](Naughty.gif) 5 | 6 | ## Requirements 7 | 8 | Swift 1.2, iOS 8.0 9 | 10 | ## Example 11 | 12 | ```swift 13 | starImageView.frame = CGRectMake(view.frame.width/2.0 - 32/2.0, 100, 32, 32) 14 | 15 | starImageView.setupWithImage(UIImage(named: "fav")!, horizontalImages: 8, verticalImages: 12) 16 | 17 | starImageView.startNaughtyAnimation() 18 | ``` 19 | 20 | ## Installation 21 | 22 | Feel free to drag `NaughtyImageView.swift` to your iOS Project. But it's recommended to use CocoaPods or Carthage. 23 | 24 | ### CocoaPods 25 | 26 | [CocoaPods](http://cocoapods.org) is a dependency manager for Cocoa projects. 27 | 28 | CocoaPods 0.36 adds supports for Swift and embedded frameworks. You can install it with the following command: 29 | 30 | ```bash 31 | $ [sudo] gem install cocoapods 32 | ``` 33 | 34 | To integrate NaughtyImageView into your Xcode project using CocoaPods, specify it in your `Podfile`: 35 | 36 | ```ruby 37 | source 'https://github.com/CocoaPods/Specs.git' 38 | platform :ios, '8.0' 39 | use_frameworks! 40 | 41 | pod 'NaughtyImageView' 42 | ``` 43 | 44 | Then, run the following command: 45 | 46 | ```bash 47 | $ pod install 48 | ``` 49 | 50 | You should open the `{Project}.xcworkspace` instead of the `{Project}.xcodeproj` after you installed anything from CocoaPods. 51 | 52 | For more information about how to use CocoaPods, I suggest [this tutorial](http://www.raywenderlich.com/64546/introduction-to-cocoapods-2). 53 | 54 | 55 | ## License 56 | 57 | NaughtyImageView is available under the MIT license. See the LICENSE file for more info. 58 | --------------------------------------------------------------------------------