[Example-BackgroundPropertySetting] Rename example project to be compatible with build script

This commit is contained in:
Adlai Holler
2016-02-18 15:23:13 -08:00
parent e9712cdfa1
commit 78c8b039ec
20 changed files with 733 additions and 0 deletions

View File

@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="9532" systemVersion="15D21" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" initialViewController="01J-lp-oVM">
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="9530"/>
</dependencies>
<scenes>
<!--View Controller-->
<scene sceneID="EHf-IW-A2E">
<objects>
<viewController id="01J-lp-oVM" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="Llm-lL-Icb"/>
<viewControllerLayoutGuide type="bottom" id="xb3-aO-Qok"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="53" y="375"/>
</scene>
</scenes>
</document>

View File

@@ -0,0 +1,368 @@
// !$*UTF8*$!
{
archiveVersion = 1;
classes = {
};
objectVersion = 46;
objects = {
/* Begin PBXBuildFile section */
13C5ECD49F2371E08EBD30F7 /* Pods.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B36F7F82AB7809F22F4C8635 /* Pods.framework */; };
CCB8301E1C7688B500847D42 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = CCB8301D1C7688B500847D42 /* Assets.xcassets */; };
CCB830211C7688B500847D42 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = CCB8301F1C7688B500847D42 /* LaunchScreen.storyboard */; };
CCB8302C1C7688EC00847D42 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = CCB830281C7688EC00847D42 /* AppDelegate.swift */; };
CCB8302D1C7688EC00847D42 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = CCB830291C7688EC00847D42 /* ViewController.swift */; };
CCB8302E1C7688EC00847D42 /* Utilities.swift in Sources */ = {isa = PBXBuildFile; fileRef = CCB8302A1C7688EC00847D42 /* Utilities.swift */; };
CCB8302F1C7688EC00847D42 /* DemoCellNode.swift in Sources */ = {isa = PBXBuildFile; fileRef = CCB8302B1C7688EC00847D42 /* DemoCellNode.swift */; };
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
811311717C2489CE07A1B9D0 /* Pods.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = Pods.release.xcconfig; path = "Pods/Target Support Files/Pods/Pods.release.xcconfig"; sourceTree = "<group>"; };
B36F7F82AB7809F22F4C8635 /* Pods.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods.framework; sourceTree = BUILT_PRODUCTS_DIR; };
BC1DAB40E0D262E674E35EEF /* Pods.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = Pods.debug.xcconfig; path = "Pods/Target Support Files/Pods/Pods.debug.xcconfig"; sourceTree = "<group>"; };
CCB830131C7688B500847D42 /* Sample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Sample.app; sourceTree = BUILT_PRODUCTS_DIR; };
CCB8301D1C7688B500847D42 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
CCB830201C7688B500847D42 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
CCB830221C7688B500847D42 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
CCB830281C7688EC00847D42 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
CCB830291C7688EC00847D42 /* ViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = "<group>"; };
CCB8302A1C7688EC00847D42 /* Utilities.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Utilities.swift; sourceTree = "<group>"; };
CCB8302B1C7688EC00847D42 /* DemoCellNode.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DemoCellNode.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
CCB830101C7688B500847D42 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
13C5ECD49F2371E08EBD30F7 /* Pods.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
2D17B5A68E217F63F504A0AB /* Pods */ = {
isa = PBXGroup;
children = (
BC1DAB40E0D262E674E35EEF /* Pods.debug.xcconfig */,
811311717C2489CE07A1B9D0 /* Pods.release.xcconfig */,
);
name = Pods;
sourceTree = "<group>";
};
4C1A8C0BFF16C5457DF86019 /* Frameworks */ = {
isa = PBXGroup;
children = (
B36F7F82AB7809F22F4C8635 /* Pods.framework */,
);
name = Frameworks;
sourceTree = "<group>";
};
CCB8300A1C7688B500847D42 = {
isa = PBXGroup;
children = (
CCB830151C7688B500847D42 /* Sample */,
CCB830141C7688B500847D42 /* Products */,
2D17B5A68E217F63F504A0AB /* Pods */,
4C1A8C0BFF16C5457DF86019 /* Frameworks */,
);
sourceTree = "<group>";
};
CCB830141C7688B500847D42 /* Products */ = {
isa = PBXGroup;
children = (
CCB830131C7688B500847D42 /* Sample.app */,
);
name = Products;
sourceTree = "<group>";
};
CCB830151C7688B500847D42 /* Sample */ = {
isa = PBXGroup;
children = (
CCB830281C7688EC00847D42 /* AppDelegate.swift */,
CCB830291C7688EC00847D42 /* ViewController.swift */,
CCB8302A1C7688EC00847D42 /* Utilities.swift */,
CCB8302B1C7688EC00847D42 /* DemoCellNode.swift */,
CCB8301D1C7688B500847D42 /* Assets.xcassets */,
CCB8301F1C7688B500847D42 /* LaunchScreen.storyboard */,
CCB830221C7688B500847D42 /* Info.plist */,
);
path = Sample;
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
CCB830121C7688B500847D42 /* Sample */ = {
isa = PBXNativeTarget;
buildConfigurationList = CCB830251C7688B500847D42 /* Build configuration list for PBXNativeTarget "Sample" */;
buildPhases = (
95C31681ADDC41EDF46E7EDD /* Check Pods Manifest.lock */,
CCB8300F1C7688B500847D42 /* Sources */,
CCB830101C7688B500847D42 /* Frameworks */,
CCB830111C7688B500847D42 /* Resources */,
D7905F8C75C02D4B15A13055 /* Embed Pods Frameworks */,
FC69305B914BC44642AD442E /* Copy Pods Resources */,
);
buildRules = (
);
dependencies = (
);
name = Sample;
productName = Sample;
productReference = CCB830131C7688B500847D42 /* Sample.app */;
productType = "com.apple.product-type.application";
};
/* End PBXNativeTarget section */
/* Begin PBXProject section */
CCB8300B1C7688B500847D42 /* Project object */ = {
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0720;
LastUpgradeCheck = 0720;
ORGANIZATIONNAME = "Adlai Holler";
TargetAttributes = {
CCB830121C7688B500847D42 = {
CreatedOnToolsVersion = 7.2.1;
};
};
};
buildConfigurationList = CCB8300E1C7688B500847D42 /* Build configuration list for PBXProject "Sample" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
hasScannedForEncodings = 0;
knownRegions = (
en,
Base,
);
mainGroup = CCB8300A1C7688B500847D42;
productRefGroup = CCB830141C7688B500847D42 /* Products */;
projectDirPath = "";
projectRoot = "";
targets = (
CCB830121C7688B500847D42 /* Sample */,
);
};
/* End PBXProject section */
/* Begin PBXResourcesBuildPhase section */
CCB830111C7688B500847D42 /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
CCB830211C7688B500847D42 /* LaunchScreen.storyboard in Resources */,
CCB8301E1C7688B500847D42 /* Assets.xcassets in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXResourcesBuildPhase section */
/* Begin PBXShellScriptBuildPhase section */
95C31681ADDC41EDF46E7EDD /* Check Pods Manifest.lock */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "Check Pods Manifest.lock";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [[ $? != 0 ]] ; then\n cat << EOM\nerror: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\nEOM\n exit 1\nfi\n";
showEnvVarsInLog = 0;
};
D7905F8C75C02D4B15A13055 /* Embed Pods Frameworks */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "Embed Pods Frameworks";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods/Pods-frameworks.sh\"\n";
showEnvVarsInLog = 0;
};
FC69305B914BC44642AD442E /* Copy Pods Resources */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "Copy Pods Resources";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods/Pods-resources.sh\"\n";
showEnvVarsInLog = 0;
};
/* End PBXShellScriptBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
CCB8300F1C7688B500847D42 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
CCB8302F1C7688EC00847D42 /* DemoCellNode.swift in Sources */,
CCB8302E1C7688EC00847D42 /* Utilities.swift in Sources */,
CCB8302D1C7688EC00847D42 /* ViewController.swift in Sources */,
CCB8302C1C7688EC00847D42 /* AppDelegate.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */
/* Begin PBXVariantGroup section */
CCB8301F1C7688B500847D42 /* LaunchScreen.storyboard */ = {
isa = PBXVariantGroup;
children = (
CCB830201C7688B500847D42 /* Base */,
);
name = LaunchScreen.storyboard;
sourceTree = "<group>";
};
/* End PBXVariantGroup section */
/* Begin XCBuildConfiguration section */
CCB830231C7688B500847D42 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = dwarf;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_DYNAMIC_NO_PIC = NO;
GCC_NO_COMMON_BLOCKS = YES;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
);
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 9.2;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
};
name = Debug;
};
CCB830241C7688B500847D42 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_NO_COMMON_BLOCKS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 9.2;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
VALIDATE_PRODUCT = YES;
};
name = Release;
};
CCB830261C7688B500847D42 /* Debug */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = BC1DAB40E0D262E674E35EEF /* Pods.debug.xcconfig */;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
INFOPLIST_FILE = Sample/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = adlai.Sample;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
};
name = Debug;
};
CCB830271C7688B500847D42 /* Release */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 811311717C2489CE07A1B9D0 /* Pods.release.xcconfig */;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
INFOPLIST_FILE = Sample/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = adlai.Sample;
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Release;
};
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
CCB8300E1C7688B500847D42 /* Build configuration list for PBXProject "Sample" */ = {
isa = XCConfigurationList;
buildConfigurations = (
CCB830231C7688B500847D42 /* Debug */,
CCB830241C7688B500847D42 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
CCB830251C7688B500847D42 /* Build configuration list for PBXNativeTarget "Sample" */ = {
isa = XCConfigurationList;
buildConfigurations = (
CCB830261C7688B500847D42 /* Debug */,
CCB830271C7688B500847D42 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
rootObject = CCB8300B1C7688B500847D42 /* Project object */;
}

View File

@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<FileRef
location = "self:Sample.xcodeproj">
</FileRef>
</Workspace>

View File

@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<FileRef
location = "group:Sample.xcodeproj">
</FileRef>
<FileRef
location = "group:Pods/Pods.xcodeproj">
</FileRef>
</Workspace>

View File

@@ -0,0 +1,50 @@
//
// AppDelegate.swift
// BackgroundPropertySetting
//
// Created by Adlai Holler on 2/17/16.
// Copyright © 2016 Adlai Holler. All rights reserved.
//
import UIKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
let window = UIWindow(frame: UIScreen.mainScreen().bounds)
self.window = window
let vc = ViewController()
window.rootViewController = UINavigationController(rootViewController: vc)
window.makeKeyAndVisible()
return true
}
func applicationWillResignActive(application: UIApplication) {
// 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.
// 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.
}
func applicationDidEnterBackground(application: UIApplication) {
// 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.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}
func applicationWillEnterForeground(application: UIApplication) {
// 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.
}
func applicationDidBecomeActive(application: UIApplication) {
// 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.
}
func applicationWillTerminate(application: UIApplication) {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}
}

View File

@@ -0,0 +1,38 @@
{
"images" : [
{
"idiom" : "iphone",
"size" : "29x29",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "29x29",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "40x40",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "40x40",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "60x60",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "60x60",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}

View File

@@ -0,0 +1,87 @@
//
// DemoCellNode.swift
// BackgroundPropertySetting
//
// Created by Adlai Holler on 2/17/16.
// Copyright © 2016 Adlai Holler. All rights reserved.
//
import UIKit
import AsyncDisplayKit
final class DemoCellNode: ASCellNode {
let childA = ASDisplayNode()
let childB = ASDisplayNode()
var state = State.Right
override init() {
super.init()
usesImplicitHierarchyManagement = true
}
override func layoutSpecThatFits(constrainedSize: ASSizeRange) -> ASLayoutSpec {
let specA = ASRatioLayoutSpec(ratio: 1, child: childA)
specA.flexBasis = ASRelativeDimensionMakeWithPoints(1)
specA.flexGrow = true
let specB = ASRatioLayoutSpec(ratio: 1, child: childB)
specB.flexBasis = ASRelativeDimensionMakeWithPoints(1)
specB.flexGrow = true
let children = state.isReverse ? [ specB, specA ] : [ specA, specB ]
let direction: ASStackLayoutDirection = state.isVertical ? .Vertical : .Horizontal
return ASStackLayoutSpec(direction: direction,
spacing: 20,
justifyContent: .SpaceAround,
alignItems: .Center,
children: children)
}
override func animateLayoutTransition(context: ASContextTransitioning!) {
childA.frame = context.initialFrameForNode(childA)
childB.frame = context.initialFrameForNode(childB)
let tinyDelay = drand48() / 10
UIView.animateWithDuration(0.5, delay: tinyDelay, usingSpringWithDamping: 0.9, initialSpringVelocity: 1.5, options: .BeginFromCurrentState, animations: { () -> Void in
self.childA.frame = context.finalFrameForNode(self.childA)
self.childB.frame = context.finalFrameForNode(self.childB)
}, completion: {
context.completeTransition($0)
})
}
enum State {
case Right
case Up
case Left
case Down
var isVertical: Bool {
switch self {
case .Up, .Down:
return true
default:
return false
}
}
var isReverse: Bool {
switch self {
case .Left, .Up:
return true
default:
return false
}
}
mutating func advance() {
switch self {
case .Right:
self = .Up
case .Up:
self = .Left
case .Left:
self = .Down
case .Down:
self = .Right
}
}
}
}

View File

@@ -0,0 +1,36 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>armv7</string>
</array>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
</array>
</dict>
</plist>

View File

@@ -0,0 +1,15 @@
//
// Utilities.swift
// BackgroundPropertySetting
//
// Created by Adlai Holler on 2/17/16.
// Copyright © 2016 Adlai Holler. All rights reserved.
//
import UIKit
extension UIColor {
static func random() -> UIColor {
return UIColor(red: CGFloat(drand48()), green: CGFloat(drand48()), blue: CGFloat(drand48()), alpha: 1.0)
}
}

View File

@@ -0,0 +1,95 @@
//
// ViewController.swift
// BackgroundPropertySetting
//
// Created by Adlai Holler on 2/17/16.
// Copyright © 2016 Adlai Holler. All rights reserved.
//
import UIKit
import AsyncDisplayKit
final class ViewController: ASViewController, ASCollectionDelegate, ASCollectionDataSource {
let itemCount = 1000
let itemSize: CGSize
let padding: CGFloat
var collectionNode: ASCollectionNode {
return node as! ASCollectionNode
}
init() {
let layout = UICollectionViewFlowLayout()
(padding, itemSize) = ViewController.computeLayoutSizesForMainScreen()
layout.minimumInteritemSpacing = padding
layout.minimumLineSpacing = padding
super.init(node: ASCollectionNode(collectionViewLayout: layout))
navigationItem.rightBarButtonItem = UIBarButtonItem(title: "Color", style: .Plain, target: self, action: "didTapColorsButton")
navigationItem.leftBarButtonItem = UIBarButtonItem(title: "Layout", style: .Plain, target: self, action: "didTapLayoutButton")
collectionNode.delegate = self
collectionNode.dataSource = self
title = "Background Updating"
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
// MARK: ASCollectionDataSource
func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return itemCount
}
func collectionView(collectionView: ASCollectionView, nodeBlockForItemAtIndexPath indexPath: NSIndexPath) -> ASCellNodeBlock {
return {
let node = DemoCellNode()
node.backgroundColor = UIColor.random()
node.childA.backgroundColor = UIColor.random()
node.childB.backgroundColor = UIColor.random()
return node
}
}
func collectionView(collectionView: ASCollectionView, constrainedSizeForNodeAtIndexPath indexPath: NSIndexPath) -> ASSizeRange {
return ASSizeRangeMake(itemSize, itemSize)
}
// MARK: Action Handling
@objc private func didTapColorsButton() {
let currentlyVisibleNodes = collectionNode.view.visibleNodes()
let queue = dispatch_get_global_queue(QOS_CLASS_DEFAULT, 0)
dispatch_async(queue) {
for case let node as DemoCellNode in currentlyVisibleNodes {
node.backgroundColor = UIColor.random()
}
}
}
@objc private func didTapLayoutButton() {
let currentlyVisibleNodes = collectionNode.view.visibleNodes()
let queue = dispatch_get_global_queue(QOS_CLASS_DEFAULT, 0)
dispatch_async(queue) {
for case let node as DemoCellNode in currentlyVisibleNodes {
node.state.advance()
node.setNeedsLayout()
}
}
}
// MARK: Static
static func computeLayoutSizesForMainScreen() -> (padding: CGFloat, itemSize: CGSize) {
let numberOfColumns = 4
let screen = UIScreen.mainScreen()
let scale = screen.scale
let screenWidth = Int(screen.bounds.width * screen.scale)
let itemWidthPx = (screenWidth - (numberOfColumns - 1)) / numberOfColumns
let leftover = screenWidth - itemWidthPx * numberOfColumns
let paddingPx = leftover / (numberOfColumns - 1)
let itemDimension = CGFloat(itemWidthPx) / scale
let padding = CGFloat(paddingPx) / scale
return (padding: padding, itemSize: CGSize(width: itemDimension, height: itemDimension))
}
}