├── .gitignore ├── CADisplayLinkDemo.xcodeproj ├── project.pbxproj └── project.xcworkspace │ └── contents.xcworkspacedata ├── CADisplayLinkDemo ├── AppDelegate.h ├── AppDelegate.m ├── Base.lproj │ ├── LaunchScreen.xib │ └── Main.storyboard ├── BlockView.h ├── BlockView.m ├── Images.xcassets │ └── AppIcon.appiconset │ │ └── Contents.json ├── Info.plist ├── ViewController.h ├── ViewController.m └── main.m ├── CADisplayLinkDemoTests ├── CADisplayLinkDemoTests.m └── Info.plist ├── README.md └── demo.gif /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | *.swp 3 | *~.nib 4 | 5 | build/ 6 | xcuserdata/ 7 | *.pbxuser 8 | *.perspective 9 | *.perspectivev3 10 | -------------------------------------------------------------------------------- /CADisplayLinkDemo.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | FA59A0A81AB29AF70095C04D /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = FA59A0A71AB29AF70095C04D /* main.m */; }; 11 | FA59A0AB1AB29AF70095C04D /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = FA59A0AA1AB29AF70095C04D /* AppDelegate.m */; }; 12 | FA59A0AE1AB29AF70095C04D /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = FA59A0AD1AB29AF70095C04D /* ViewController.m */; }; 13 | FA59A0B11AB29AF70095C04D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = FA59A0AF1AB29AF70095C04D /* Main.storyboard */; }; 14 | FA59A0B31AB29AF70095C04D /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = FA59A0B21AB29AF70095C04D /* Images.xcassets */; }; 15 | FA59A0B61AB29AF70095C04D /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = FA59A0B41AB29AF70095C04D /* LaunchScreen.xib */; }; 16 | FA59A0C21AB29AF80095C04D /* CADisplayLinkDemoTests.m in Sources */ = {isa = PBXBuildFile; fileRef = FA59A0C11AB29AF80095C04D /* CADisplayLinkDemoTests.m */; }; 17 | FA59A0CD1AB2AAA80095C04D /* BlockView.m in Sources */ = {isa = PBXBuildFile; fileRef = FA59A0CC1AB2AAA80095C04D /* BlockView.m */; }; 18 | /* End PBXBuildFile section */ 19 | 20 | /* Begin PBXContainerItemProxy section */ 21 | FA59A0BC1AB29AF80095C04D /* PBXContainerItemProxy */ = { 22 | isa = PBXContainerItemProxy; 23 | containerPortal = FA59A09A1AB29AF70095C04D /* Project object */; 24 | proxyType = 1; 25 | remoteGlobalIDString = FA59A0A11AB29AF70095C04D; 26 | remoteInfo = CADisplayLinkDemo; 27 | }; 28 | /* End PBXContainerItemProxy section */ 29 | 30 | /* Begin PBXFileReference section */ 31 | FA59A0A21AB29AF70095C04D /* CADisplayLinkDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = CADisplayLinkDemo.app; sourceTree = BUILT_PRODUCTS_DIR; }; 32 | FA59A0A61AB29AF70095C04D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 33 | FA59A0A71AB29AF70095C04D /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 34 | FA59A0A91AB29AF70095C04D /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 35 | FA59A0AA1AB29AF70095C04D /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 36 | FA59A0AC1AB29AF70095C04D /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; 37 | FA59A0AD1AB29AF70095C04D /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; 38 | FA59A0B01AB29AF70095C04D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 39 | FA59A0B21AB29AF70095C04D /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; 40 | FA59A0B51AB29AF70095C04D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/LaunchScreen.xib; sourceTree = ""; }; 41 | FA59A0BB1AB29AF80095C04D /* CADisplayLinkDemoTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = CADisplayLinkDemoTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 42 | FA59A0C01AB29AF80095C04D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 43 | FA59A0C11AB29AF80095C04D /* CADisplayLinkDemoTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CADisplayLinkDemoTests.m; sourceTree = ""; }; 44 | FA59A0CB1AB2AAA80095C04D /* BlockView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BlockView.h; sourceTree = ""; }; 45 | FA59A0CC1AB2AAA80095C04D /* BlockView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BlockView.m; sourceTree = ""; }; 46 | /* End PBXFileReference section */ 47 | 48 | /* Begin PBXFrameworksBuildPhase section */ 49 | FA59A09F1AB29AF70095C04D /* Frameworks */ = { 50 | isa = PBXFrameworksBuildPhase; 51 | buildActionMask = 2147483647; 52 | files = ( 53 | ); 54 | runOnlyForDeploymentPostprocessing = 0; 55 | }; 56 | FA59A0B81AB29AF80095C04D /* Frameworks */ = { 57 | isa = PBXFrameworksBuildPhase; 58 | buildActionMask = 2147483647; 59 | files = ( 60 | ); 61 | runOnlyForDeploymentPostprocessing = 0; 62 | }; 63 | /* End PBXFrameworksBuildPhase section */ 64 | 65 | /* Begin PBXGroup section */ 66 | FA59A0991AB29AF70095C04D = { 67 | isa = PBXGroup; 68 | children = ( 69 | FA59A0A41AB29AF70095C04D /* CADisplayLinkDemo */, 70 | FA59A0BE1AB29AF80095C04D /* CADisplayLinkDemoTests */, 71 | FA59A0A31AB29AF70095C04D /* Products */, 72 | ); 73 | sourceTree = ""; 74 | }; 75 | FA59A0A31AB29AF70095C04D /* Products */ = { 76 | isa = PBXGroup; 77 | children = ( 78 | FA59A0A21AB29AF70095C04D /* CADisplayLinkDemo.app */, 79 | FA59A0BB1AB29AF80095C04D /* CADisplayLinkDemoTests.xctest */, 80 | ); 81 | name = Products; 82 | sourceTree = ""; 83 | }; 84 | FA59A0A41AB29AF70095C04D /* CADisplayLinkDemo */ = { 85 | isa = PBXGroup; 86 | children = ( 87 | FA59A0A91AB29AF70095C04D /* AppDelegate.h */, 88 | FA59A0AA1AB29AF70095C04D /* AppDelegate.m */, 89 | FA59A0AC1AB29AF70095C04D /* ViewController.h */, 90 | FA59A0AD1AB29AF70095C04D /* ViewController.m */, 91 | FA59A0CB1AB2AAA80095C04D /* BlockView.h */, 92 | FA59A0CC1AB2AAA80095C04D /* BlockView.m */, 93 | FA59A0AF1AB29AF70095C04D /* Main.storyboard */, 94 | FA59A0B21AB29AF70095C04D /* Images.xcassets */, 95 | FA59A0B41AB29AF70095C04D /* LaunchScreen.xib */, 96 | FA59A0A51AB29AF70095C04D /* Supporting Files */, 97 | ); 98 | path = CADisplayLinkDemo; 99 | sourceTree = ""; 100 | }; 101 | FA59A0A51AB29AF70095C04D /* Supporting Files */ = { 102 | isa = PBXGroup; 103 | children = ( 104 | FA59A0A61AB29AF70095C04D /* Info.plist */, 105 | FA59A0A71AB29AF70095C04D /* main.m */, 106 | ); 107 | name = "Supporting Files"; 108 | sourceTree = ""; 109 | }; 110 | FA59A0BE1AB29AF80095C04D /* CADisplayLinkDemoTests */ = { 111 | isa = PBXGroup; 112 | children = ( 113 | FA59A0C11AB29AF80095C04D /* CADisplayLinkDemoTests.m */, 114 | FA59A0BF1AB29AF80095C04D /* Supporting Files */, 115 | ); 116 | path = CADisplayLinkDemoTests; 117 | sourceTree = ""; 118 | }; 119 | FA59A0BF1AB29AF80095C04D /* Supporting Files */ = { 120 | isa = PBXGroup; 121 | children = ( 122 | FA59A0C01AB29AF80095C04D /* Info.plist */, 123 | ); 124 | name = "Supporting Files"; 125 | sourceTree = ""; 126 | }; 127 | /* End PBXGroup section */ 128 | 129 | /* Begin PBXNativeTarget section */ 130 | FA59A0A11AB29AF70095C04D /* CADisplayLinkDemo */ = { 131 | isa = PBXNativeTarget; 132 | buildConfigurationList = FA59A0C51AB29AF80095C04D /* Build configuration list for PBXNativeTarget "CADisplayLinkDemo" */; 133 | buildPhases = ( 134 | FA59A09E1AB29AF70095C04D /* Sources */, 135 | FA59A09F1AB29AF70095C04D /* Frameworks */, 136 | FA59A0A01AB29AF70095C04D /* Resources */, 137 | ); 138 | buildRules = ( 139 | ); 140 | dependencies = ( 141 | ); 142 | name = CADisplayLinkDemo; 143 | productName = CADisplayLinkDemo; 144 | productReference = FA59A0A21AB29AF70095C04D /* CADisplayLinkDemo.app */; 145 | productType = "com.apple.product-type.application"; 146 | }; 147 | FA59A0BA1AB29AF80095C04D /* CADisplayLinkDemoTests */ = { 148 | isa = PBXNativeTarget; 149 | buildConfigurationList = FA59A0C81AB29AF80095C04D /* Build configuration list for PBXNativeTarget "CADisplayLinkDemoTests" */; 150 | buildPhases = ( 151 | FA59A0B71AB29AF80095C04D /* Sources */, 152 | FA59A0B81AB29AF80095C04D /* Frameworks */, 153 | FA59A0B91AB29AF80095C04D /* Resources */, 154 | ); 155 | buildRules = ( 156 | ); 157 | dependencies = ( 158 | FA59A0BD1AB29AF80095C04D /* PBXTargetDependency */, 159 | ); 160 | name = CADisplayLinkDemoTests; 161 | productName = CADisplayLinkDemoTests; 162 | productReference = FA59A0BB1AB29AF80095C04D /* CADisplayLinkDemoTests.xctest */; 163 | productType = "com.apple.product-type.bundle.unit-test"; 164 | }; 165 | /* End PBXNativeTarget section */ 166 | 167 | /* Begin PBXProject section */ 168 | FA59A09A1AB29AF70095C04D /* Project object */ = { 169 | isa = PBXProject; 170 | attributes = { 171 | LastUpgradeCheck = 0610; 172 | ORGANIZATIONNAME = glow; 173 | TargetAttributes = { 174 | FA59A0A11AB29AF70095C04D = { 175 | CreatedOnToolsVersion = 6.1.1; 176 | }; 177 | FA59A0BA1AB29AF80095C04D = { 178 | CreatedOnToolsVersion = 6.1.1; 179 | TestTargetID = FA59A0A11AB29AF70095C04D; 180 | }; 181 | }; 182 | }; 183 | buildConfigurationList = FA59A09D1AB29AF70095C04D /* Build configuration list for PBXProject "CADisplayLinkDemo" */; 184 | compatibilityVersion = "Xcode 3.2"; 185 | developmentRegion = English; 186 | hasScannedForEncodings = 0; 187 | knownRegions = ( 188 | en, 189 | Base, 190 | ); 191 | mainGroup = FA59A0991AB29AF70095C04D; 192 | productRefGroup = FA59A0A31AB29AF70095C04D /* Products */; 193 | projectDirPath = ""; 194 | projectRoot = ""; 195 | targets = ( 196 | FA59A0A11AB29AF70095C04D /* CADisplayLinkDemo */, 197 | FA59A0BA1AB29AF80095C04D /* CADisplayLinkDemoTests */, 198 | ); 199 | }; 200 | /* End PBXProject section */ 201 | 202 | /* Begin PBXResourcesBuildPhase section */ 203 | FA59A0A01AB29AF70095C04D /* Resources */ = { 204 | isa = PBXResourcesBuildPhase; 205 | buildActionMask = 2147483647; 206 | files = ( 207 | FA59A0B11AB29AF70095C04D /* Main.storyboard in Resources */, 208 | FA59A0B61AB29AF70095C04D /* LaunchScreen.xib in Resources */, 209 | FA59A0B31AB29AF70095C04D /* Images.xcassets in Resources */, 210 | ); 211 | runOnlyForDeploymentPostprocessing = 0; 212 | }; 213 | FA59A0B91AB29AF80095C04D /* Resources */ = { 214 | isa = PBXResourcesBuildPhase; 215 | buildActionMask = 2147483647; 216 | files = ( 217 | ); 218 | runOnlyForDeploymentPostprocessing = 0; 219 | }; 220 | /* End PBXResourcesBuildPhase section */ 221 | 222 | /* Begin PBXSourcesBuildPhase section */ 223 | FA59A09E1AB29AF70095C04D /* Sources */ = { 224 | isa = PBXSourcesBuildPhase; 225 | buildActionMask = 2147483647; 226 | files = ( 227 | FA59A0CD1AB2AAA80095C04D /* BlockView.m in Sources */, 228 | FA59A0AE1AB29AF70095C04D /* ViewController.m in Sources */, 229 | FA59A0AB1AB29AF70095C04D /* AppDelegate.m in Sources */, 230 | FA59A0A81AB29AF70095C04D /* main.m in Sources */, 231 | ); 232 | runOnlyForDeploymentPostprocessing = 0; 233 | }; 234 | FA59A0B71AB29AF80095C04D /* Sources */ = { 235 | isa = PBXSourcesBuildPhase; 236 | buildActionMask = 2147483647; 237 | files = ( 238 | FA59A0C21AB29AF80095C04D /* CADisplayLinkDemoTests.m in Sources */, 239 | ); 240 | runOnlyForDeploymentPostprocessing = 0; 241 | }; 242 | /* End PBXSourcesBuildPhase section */ 243 | 244 | /* Begin PBXTargetDependency section */ 245 | FA59A0BD1AB29AF80095C04D /* PBXTargetDependency */ = { 246 | isa = PBXTargetDependency; 247 | target = FA59A0A11AB29AF70095C04D /* CADisplayLinkDemo */; 248 | targetProxy = FA59A0BC1AB29AF80095C04D /* PBXContainerItemProxy */; 249 | }; 250 | /* End PBXTargetDependency section */ 251 | 252 | /* Begin PBXVariantGroup section */ 253 | FA59A0AF1AB29AF70095C04D /* Main.storyboard */ = { 254 | isa = PBXVariantGroup; 255 | children = ( 256 | FA59A0B01AB29AF70095C04D /* Base */, 257 | ); 258 | name = Main.storyboard; 259 | sourceTree = ""; 260 | }; 261 | FA59A0B41AB29AF70095C04D /* LaunchScreen.xib */ = { 262 | isa = PBXVariantGroup; 263 | children = ( 264 | FA59A0B51AB29AF70095C04D /* Base */, 265 | ); 266 | name = LaunchScreen.xib; 267 | sourceTree = ""; 268 | }; 269 | /* End PBXVariantGroup section */ 270 | 271 | /* Begin XCBuildConfiguration section */ 272 | FA59A0C31AB29AF80095C04D /* Debug */ = { 273 | isa = XCBuildConfiguration; 274 | buildSettings = { 275 | ALWAYS_SEARCH_USER_PATHS = NO; 276 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 277 | CLANG_CXX_LIBRARY = "libc++"; 278 | CLANG_ENABLE_MODULES = YES; 279 | CLANG_ENABLE_OBJC_ARC = YES; 280 | CLANG_WARN_BOOL_CONVERSION = YES; 281 | CLANG_WARN_CONSTANT_CONVERSION = YES; 282 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 283 | CLANG_WARN_EMPTY_BODY = YES; 284 | CLANG_WARN_ENUM_CONVERSION = YES; 285 | CLANG_WARN_INT_CONVERSION = YES; 286 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 287 | CLANG_WARN_UNREACHABLE_CODE = YES; 288 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 289 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 290 | COPY_PHASE_STRIP = NO; 291 | ENABLE_STRICT_OBJC_MSGSEND = YES; 292 | GCC_C_LANGUAGE_STANDARD = gnu99; 293 | GCC_DYNAMIC_NO_PIC = NO; 294 | GCC_OPTIMIZATION_LEVEL = 0; 295 | GCC_PREPROCESSOR_DEFINITIONS = ( 296 | "DEBUG=1", 297 | "$(inherited)", 298 | ); 299 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 300 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 301 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 302 | GCC_WARN_UNDECLARED_SELECTOR = YES; 303 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 304 | GCC_WARN_UNUSED_FUNCTION = YES; 305 | GCC_WARN_UNUSED_VARIABLE = YES; 306 | IPHONEOS_DEPLOYMENT_TARGET = 8.1; 307 | MTL_ENABLE_DEBUG_INFO = YES; 308 | ONLY_ACTIVE_ARCH = YES; 309 | SDKROOT = iphoneos; 310 | }; 311 | name = Debug; 312 | }; 313 | FA59A0C41AB29AF80095C04D /* 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_INT_CONVERSION = YES; 327 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 328 | CLANG_WARN_UNREACHABLE_CODE = YES; 329 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 330 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 331 | COPY_PHASE_STRIP = YES; 332 | ENABLE_NS_ASSERTIONS = NO; 333 | ENABLE_STRICT_OBJC_MSGSEND = YES; 334 | GCC_C_LANGUAGE_STANDARD = gnu99; 335 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 336 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 337 | GCC_WARN_UNDECLARED_SELECTOR = YES; 338 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 339 | GCC_WARN_UNUSED_FUNCTION = YES; 340 | GCC_WARN_UNUSED_VARIABLE = YES; 341 | IPHONEOS_DEPLOYMENT_TARGET = 8.1; 342 | MTL_ENABLE_DEBUG_INFO = NO; 343 | SDKROOT = iphoneos; 344 | VALIDATE_PRODUCT = YES; 345 | }; 346 | name = Release; 347 | }; 348 | FA59A0C61AB29AF80095C04D /* Debug */ = { 349 | isa = XCBuildConfiguration; 350 | buildSettings = { 351 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 352 | INFOPLIST_FILE = CADisplayLinkDemo/Info.plist; 353 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 354 | PRODUCT_NAME = "$(TARGET_NAME)"; 355 | }; 356 | name = Debug; 357 | }; 358 | FA59A0C71AB29AF80095C04D /* Release */ = { 359 | isa = XCBuildConfiguration; 360 | buildSettings = { 361 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 362 | INFOPLIST_FILE = CADisplayLinkDemo/Info.plist; 363 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 364 | PRODUCT_NAME = "$(TARGET_NAME)"; 365 | }; 366 | name = Release; 367 | }; 368 | FA59A0C91AB29AF80095C04D /* Debug */ = { 369 | isa = XCBuildConfiguration; 370 | buildSettings = { 371 | BUNDLE_LOADER = "$(TEST_HOST)"; 372 | FRAMEWORK_SEARCH_PATHS = ( 373 | "$(SDKROOT)/Developer/Library/Frameworks", 374 | "$(inherited)", 375 | ); 376 | GCC_PREPROCESSOR_DEFINITIONS = ( 377 | "DEBUG=1", 378 | "$(inherited)", 379 | ); 380 | INFOPLIST_FILE = CADisplayLinkDemoTests/Info.plist; 381 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 382 | PRODUCT_NAME = "$(TARGET_NAME)"; 383 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/CADisplayLinkDemo.app/CADisplayLinkDemo"; 384 | }; 385 | name = Debug; 386 | }; 387 | FA59A0CA1AB29AF80095C04D /* Release */ = { 388 | isa = XCBuildConfiguration; 389 | buildSettings = { 390 | BUNDLE_LOADER = "$(TEST_HOST)"; 391 | FRAMEWORK_SEARCH_PATHS = ( 392 | "$(SDKROOT)/Developer/Library/Frameworks", 393 | "$(inherited)", 394 | ); 395 | INFOPLIST_FILE = CADisplayLinkDemoTests/Info.plist; 396 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 397 | PRODUCT_NAME = "$(TARGET_NAME)"; 398 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/CADisplayLinkDemo.app/CADisplayLinkDemo"; 399 | }; 400 | name = Release; 401 | }; 402 | /* End XCBuildConfiguration section */ 403 | 404 | /* Begin XCConfigurationList section */ 405 | FA59A09D1AB29AF70095C04D /* Build configuration list for PBXProject "CADisplayLinkDemo" */ = { 406 | isa = XCConfigurationList; 407 | buildConfigurations = ( 408 | FA59A0C31AB29AF80095C04D /* Debug */, 409 | FA59A0C41AB29AF80095C04D /* Release */, 410 | ); 411 | defaultConfigurationIsVisible = 0; 412 | defaultConfigurationName = Release; 413 | }; 414 | FA59A0C51AB29AF80095C04D /* Build configuration list for PBXNativeTarget "CADisplayLinkDemo" */ = { 415 | isa = XCConfigurationList; 416 | buildConfigurations = ( 417 | FA59A0C61AB29AF80095C04D /* Debug */, 418 | FA59A0C71AB29AF80095C04D /* Release */, 419 | ); 420 | defaultConfigurationIsVisible = 0; 421 | }; 422 | FA59A0C81AB29AF80095C04D /* Build configuration list for PBXNativeTarget "CADisplayLinkDemoTests" */ = { 423 | isa = XCConfigurationList; 424 | buildConfigurations = ( 425 | FA59A0C91AB29AF80095C04D /* Debug */, 426 | FA59A0CA1AB29AF80095C04D /* Release */, 427 | ); 428 | defaultConfigurationIsVisible = 0; 429 | }; 430 | /* End XCConfigurationList section */ 431 | }; 432 | rootObject = FA59A09A1AB29AF70095C04D /* Project object */; 433 | } 434 | -------------------------------------------------------------------------------- /CADisplayLinkDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /CADisplayLinkDemo/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // CADisplayLinkDemo 4 | // 5 | // Created by ltebean on 15-3-13. 6 | // Copyright (c) 2015年 glow. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | 16 | @end 17 | 18 | -------------------------------------------------------------------------------- /CADisplayLinkDemo/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // CADisplayLinkDemo 4 | // 5 | // Created by ltebean on 15-3-13. 6 | // Copyright (c) 2015年 glow. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | 11 | @interface AppDelegate () 12 | 13 | @end 14 | 15 | @implementation AppDelegate 16 | 17 | 18 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 19 | // Override point for customization after application launch. 20 | return YES; 21 | } 22 | 23 | - (void)applicationWillResignActive:(UIApplication *)application { 24 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 25 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. 26 | } 27 | 28 | - (void)applicationDidEnterBackground:(UIApplication *)application { 29 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 30 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 31 | } 32 | 33 | - (void)applicationWillEnterForeground:(UIApplication *)application { 34 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. 35 | } 36 | 37 | - (void)applicationDidBecomeActive:(UIApplication *)application { 38 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 39 | } 40 | 41 | - (void)applicationWillTerminate:(UIApplication *)application { 42 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 43 | } 44 | 45 | @end 46 | -------------------------------------------------------------------------------- /CADisplayLinkDemo/Base.lproj/LaunchScreen.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /CADisplayLinkDemo/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /CADisplayLinkDemo/BlockView.h: -------------------------------------------------------------------------------- 1 | // 2 | // BlockView.h 3 | // CADisplayLinkDemo 4 | // 5 | // Created by ltebean on 15-3-13. 6 | // Copyright (c) 2015年 glow. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface BlockView : UIView 12 | - (void)startAnimationFrom:(CGFloat)from to:(CGFloat)to; 13 | - (void)completeAnimation; 14 | @end 15 | -------------------------------------------------------------------------------- /CADisplayLinkDemo/BlockView.m: -------------------------------------------------------------------------------- 1 | // 2 | // BlockView.m 3 | // CADisplayLinkDemo 4 | // 5 | // Created by ltebean on 15-3-13. 6 | // Copyright (c) 2015 glow. All rights reserved. 7 | // 8 | 9 | #import "BlockView.h" 10 | 11 | @interface BlockView() 12 | @property (strong, nonatomic) CADisplayLink *displayLink; 13 | @property (nonatomic) CGFloat from; 14 | @property (nonatomic) CGFloat to; 15 | @property (nonatomic) BOOL animating; 16 | @end 17 | 18 | @implementation BlockView 19 | 20 | - (void)startAnimationFrom:(CGFloat)from to:(CGFloat)to 21 | { 22 | self.from = from; 23 | self.to = to; 24 | self.animating = YES; 25 | if (self.displayLink == nil) { 26 | self.displayLink = [CADisplayLink displayLinkWithTarget:self selector:@selector(tick:)]; 27 | 28 | [self.displayLink addToRunLoop:[NSRunLoop currentRunLoop] 29 | forMode:NSDefaultRunLoopMode]; 30 | } 31 | } 32 | 33 | - (void)completeAnimation 34 | { 35 | self.animating = NO; 36 | [self.displayLink invalidate]; 37 | self.displayLink = nil; 38 | } 39 | 40 | - (void)tick:(CADisplayLink *)displayLink 41 | { 42 | [self setNeedsDisplay]; 43 | } 44 | 45 | - (void)drawRect:(CGRect)rect 46 | { 47 | CALayer *layer =self.layer.presentationLayer; 48 | 49 | CGFloat progress = 1; 50 | if (!self.animating) { 51 | progress = 1; 52 | } else { 53 | progress = 1 - (layer.position.y - self.to) / (self.from - self.to); 54 | } 55 | 56 | CGFloat height = CGRectGetHeight(rect); 57 | CGFloat deltaHeight = height / 2 * (0.5 - fabs(progress - 0.5)); 58 | NSLog(@"delta:%f", deltaHeight); 59 | 60 | CGPoint topLeft = CGPointMake(0, deltaHeight); 61 | CGPoint topRight = CGPointMake(CGRectGetWidth(rect), deltaHeight); 62 | CGPoint bottomLeft = CGPointMake(0, height); 63 | CGPoint bottomRight = CGPointMake(CGRectGetWidth(rect), height); 64 | 65 | UIBezierPath* path = [UIBezierPath bezierPath]; 66 | [[UIColor blueColor] setFill]; 67 | [path moveToPoint:topLeft]; 68 | [path addQuadCurveToPoint:topRight controlPoint:CGPointMake(CGRectGetMidX(rect), 0)]; 69 | [path addLineToPoint:bottomRight]; 70 | [path addQuadCurveToPoint:bottomLeft controlPoint:CGPointMake(CGRectGetMidX(rect), height - deltaHeight)]; 71 | [path closePath]; 72 | [path fill]; 73 | } 74 | 75 | @end 76 | -------------------------------------------------------------------------------- /CADisplayLinkDemo/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 | } -------------------------------------------------------------------------------- /CADisplayLinkDemo/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | com.glowing.$(PRODUCT_NAME:rfc1034identifier) 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 | -------------------------------------------------------------------------------- /CADisplayLinkDemo/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // CADisplayLinkDemo 4 | // 5 | // Created by ltebean on 15-3-13. 6 | // Copyright (c) 2015年 glow. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /CADisplayLinkDemo/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // CADisplayLinkDemo 4 | // 5 | // Created by ltebean on 15-3-13. 6 | // Copyright (c) 2015 glow. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | #import "BlockView.h" 11 | 12 | @interface ViewController () 13 | @property (weak, nonatomic) IBOutlet BlockView *blockView; 14 | @property (strong, nonatomic) CADisplayLink *displayLink; 15 | @property (nonatomic) BOOL animating; 16 | @end 17 | 18 | @implementation ViewController 19 | 20 | - (void)viewDidLoad { 21 | [super viewDidLoad]; 22 | // Do any additional setup after loading the view, typically from a nib. 23 | } 24 | 25 | - (IBAction)startButtonPressed:(id)sender 26 | { 27 | if (self.animating) { 28 | return; 29 | } 30 | 31 | self.animating = YES; 32 | 33 | CGFloat from = CGRectGetHeight(self.view.bounds) - CGRectGetHeight(self.blockView.bounds) / 2; 34 | CGFloat to = 100; 35 | 36 | self.blockView.center = CGPointMake(self.blockView.center.x, from); 37 | 38 | [self.blockView startAnimationFrom:from to:to]; 39 | [UIView animateWithDuration:1 delay:0 usingSpringWithDamping:0.85 initialSpringVelocity:0 options:0 animations:^{ 40 | self.blockView.center = CGPointMake(self.blockView.center.x, to); 41 | } completion:^(BOOL finished) { 42 | [self.blockView completeAnimation]; 43 | self.animating = NO; 44 | }]; 45 | } 46 | 47 | @end 48 | -------------------------------------------------------------------------------- /CADisplayLinkDemo/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // CADisplayLinkDemo 4 | // 5 | // Created by ltebean on 15-3-13. 6 | // Copyright (c) 2015年 glow. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /CADisplayLinkDemoTests/CADisplayLinkDemoTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // CADisplayLinkDemoTests.m 3 | // CADisplayLinkDemoTests 4 | // 5 | // Created by ltebean on 15-3-13. 6 | // Copyright (c) 2015年 glow. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | 12 | @interface CADisplayLinkDemoTests : XCTestCase 13 | 14 | @end 15 | 16 | @implementation CADisplayLinkDemoTests 17 | 18 | - (void)setUp { 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 | // Put teardown code here. This method is called after the invocation of each test method in the class. 25 | [super tearDown]; 26 | } 27 | 28 | - (void)testExample { 29 | // This is an example of a functional test case. 30 | XCTAssert(YES, @"Pass"); 31 | } 32 | 33 | - (void)testPerformanceExample { 34 | // This is an example of a performance test case. 35 | [self measureBlock:^{ 36 | // Put the code you want to measure the time of here. 37 | }]; 38 | } 39 | 40 | @end 41 | -------------------------------------------------------------------------------- /CADisplayLinkDemoTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | com.glowing.$(PRODUCT_NAME:rfc1034identifier) 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 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## Demo 2 | ![CADisplayLinkDemo](https://raw.githubusercontent.com/Glow-Inc/CADisplayLinkDemo/master/demo.gif) -------------------------------------------------------------------------------- /demo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Glow-Inc/CADisplayLinkDemo/af1df5c9d59711db78922885e6e72dc4c19aff0f/demo.gif --------------------------------------------------------------------------------