Update Layout Examples to ASDK 2.0 (#2551)

* Objective-c project updated to ASDK 2.0

* fix assets error

* [LayoutSpecExamples] Renamed new example project to be easier to type / find.

* [Bulid] Manually create Sample.xcscheme file to hopefully fix complaining bulid :).

* clean up project

* commentary on ASAbsoluteLayoutSpec

* address @maicki's comments
This commit is contained in:
Hannah Troisi
2016-11-06 13:47:48 -08:00
committed by GitHub
parent 735d1411d2
commit 7a373ac638
18 changed files with 1251 additions and 0 deletions

View File

@@ -0,0 +1,6 @@
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '7.0'
target 'Sample' do
pod 'AsyncDisplayKit', :path => '../..'
end

View File

@@ -0,0 +1,391 @@
// !$*UTF8*$!
{
archiveVersion = 1;
classes = {
};
objectVersion = 46;
objects = {
/* Begin PBXBuildFile section */
694993D21C8B334F00491CA5 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 694993D11C8B334F00491CA5 /* main.m */; };
694993D51C8B334F00491CA5 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 694993D41C8B334F00491CA5 /* AppDelegate.m */; };
694993D81C8B334F00491CA5 /* OverviewViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 694993D71C8B334F00491CA5 /* OverviewViewController.m */; };
694993E01C8B334F00491CA5 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 694993DE1C8B334F00491CA5 /* LaunchScreen.storyboard */; };
77E904A7F1CA1E967CBECF1B /* libPods-Sample.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 19C07F7EA804F418514FC00F /* libPods-Sample.a */; };
8032A2FC1DCD07580083C469 /* Utilities.m in Sources */ = {isa = PBXBuildFile; fileRef = 8032A2FB1DCD07580083C469 /* Utilities.m */; };
8032A2FF1DCD076E0083C469 /* LayoutExampleNodes.m in Sources */ = {isa = PBXBuildFile; fileRef = 8032A2FE1DCD076E0083C469 /* LayoutExampleNodes.m */; };
8092664B1DCD9CE1008373C2 /* OverviewCellNode.m in Sources */ = {isa = PBXBuildFile; fileRef = 8092664A1DCD9CE1008373C2 /* OverviewCellNode.m */; };
8092664E1DCDA64A008373C2 /* LayoutExampleViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 8092664D1DCDA64A008373C2 /* LayoutExampleViewController.m */; };
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
19C07F7EA804F418514FC00F /* libPods-Sample.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-Sample.a"; sourceTree = BUILT_PRODUCTS_DIR; };
49ABEBD1ABCEC54CD6585C1B /* Pods-Sample.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Sample.release.xcconfig"; path = "Pods/Target Support Files/Pods-Sample/Pods-Sample.release.xcconfig"; sourceTree = "<group>"; };
694993CD1C8B334F00491CA5 /* Sample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Sample.app; sourceTree = BUILT_PRODUCTS_DIR; };
694993D11C8B334F00491CA5 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
694993D31C8B334F00491CA5 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
694993D41C8B334F00491CA5 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = "<group>"; };
694993D61C8B334F00491CA5 /* OverviewViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = OverviewViewController.h; sourceTree = "<group>"; };
694993D71C8B334F00491CA5 /* OverviewViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = OverviewViewController.m; sourceTree = "<group>"; };
694993DF1C8B334F00491CA5 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
694993E11C8B334F00491CA5 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
8032A2FA1DCD07580083C469 /* Utilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Utilities.h; sourceTree = "<group>"; };
8032A2FB1DCD07580083C469 /* Utilities.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Utilities.m; sourceTree = "<group>"; };
8032A2FD1DCD076E0083C469 /* LayoutExampleNodes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LayoutExampleNodes.h; sourceTree = "<group>"; };
8032A2FE1DCD076E0083C469 /* LayoutExampleNodes.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LayoutExampleNodes.m; sourceTree = "<group>"; };
809266491DCD9CE1008373C2 /* OverviewCellNode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OverviewCellNode.h; sourceTree = "<group>"; };
8092664A1DCD9CE1008373C2 /* OverviewCellNode.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OverviewCellNode.m; sourceTree = "<group>"; };
8092664C1DCDA64A008373C2 /* LayoutExampleViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LayoutExampleViewController.h; sourceTree = "<group>"; };
8092664D1DCDA64A008373C2 /* LayoutExampleViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LayoutExampleViewController.m; sourceTree = "<group>"; };
C2FE4C0B2EE2F08E2186823E /* Pods-Sample.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Sample.debug.xcconfig"; path = "Pods/Target Support Files/Pods-Sample/Pods-Sample.debug.xcconfig"; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
694993CA1C8B334F00491CA5 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
77E904A7F1CA1E967CBECF1B /* libPods-Sample.a in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
694993C41C8B334F00491CA5 = {
isa = PBXGroup;
children = (
694993CF1C8B334F00491CA5 /* Sample */,
694993CE1C8B334F00491CA5 /* Products */,
B4D85F4D35E1EEC1C00CAFE8 /* Pods */,
E5CE41038A61211B6B519735 /* Frameworks */,
);
sourceTree = "<group>";
};
694993CE1C8B334F00491CA5 /* Products */ = {
isa = PBXGroup;
children = (
694993CD1C8B334F00491CA5 /* Sample.app */,
);
name = Products;
sourceTree = "<group>";
};
694993CF1C8B334F00491CA5 /* Sample */ = {
isa = PBXGroup;
children = (
694993D31C8B334F00491CA5 /* AppDelegate.h */,
694993D41C8B334F00491CA5 /* AppDelegate.m */,
694993D61C8B334F00491CA5 /* OverviewViewController.h */,
694993D71C8B334F00491CA5 /* OverviewViewController.m */,
809266491DCD9CE1008373C2 /* OverviewCellNode.h */,
8092664A1DCD9CE1008373C2 /* OverviewCellNode.m */,
8092664C1DCDA64A008373C2 /* LayoutExampleViewController.h */,
8092664D1DCDA64A008373C2 /* LayoutExampleViewController.m */,
8032A2FD1DCD076E0083C469 /* LayoutExampleNodes.h */,
8032A2FE1DCD076E0083C469 /* LayoutExampleNodes.m */,
8032A2FA1DCD07580083C469 /* Utilities.h */,
8032A2FB1DCD07580083C469 /* Utilities.m */,
694993D01C8B334F00491CA5 /* Supporting Files */,
);
path = Sample;
sourceTree = "<group>";
};
694993D01C8B334F00491CA5 /* Supporting Files */ = {
isa = PBXGroup;
children = (
694993E11C8B334F00491CA5 /* Info.plist */,
694993DE1C8B334F00491CA5 /* LaunchScreen.storyboard */,
694993D11C8B334F00491CA5 /* main.m */,
);
name = "Supporting Files";
sourceTree = "<group>";
};
B4D85F4D35E1EEC1C00CAFE8 /* Pods */ = {
isa = PBXGroup;
children = (
C2FE4C0B2EE2F08E2186823E /* Pods-Sample.debug.xcconfig */,
49ABEBD1ABCEC54CD6585C1B /* Pods-Sample.release.xcconfig */,
);
name = Pods;
sourceTree = "<group>";
};
E5CE41038A61211B6B519735 /* Frameworks */ = {
isa = PBXGroup;
children = (
19C07F7EA804F418514FC00F /* libPods-Sample.a */,
);
name = Frameworks;
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
694993CC1C8B334F00491CA5 /* Sample */ = {
isa = PBXNativeTarget;
buildConfigurationList = 694993E41C8B334F00491CA5 /* Build configuration list for PBXNativeTarget "Sample" */;
buildPhases = (
339DA21AF893915BAA46F6A1 /* [CP] Check Pods Manifest.lock */,
694993C91C8B334F00491CA5 /* Sources */,
694993CA1C8B334F00491CA5 /* Frameworks */,
694993CB1C8B334F00491CA5 /* Resources */,
06EE2E0ABEB6289D4775A867 /* [CP] Copy Pods Resources */,
23FC03B282CBD9014D868DF6 /* [CP] Embed Pods Frameworks */,
);
buildRules = (
);
dependencies = (
);
name = Sample;
productName = Sample;
productReference = 694993CD1C8B334F00491CA5 /* Sample.app */;
productType = "com.apple.product-type.application";
};
/* End PBXNativeTarget section */
/* Begin PBXProject section */
694993C51C8B334F00491CA5 /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0720;
ORGANIZATIONNAME = AsyncDisplayKit;
TargetAttributes = {
694993CC1C8B334F00491CA5 = {
CreatedOnToolsVersion = 7.2.1;
};
};
};
buildConfigurationList = 694993C81C8B334F00491CA5 /* Build configuration list for PBXProject "Sample" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
hasScannedForEncodings = 0;
knownRegions = (
en,
Base,
);
mainGroup = 694993C41C8B334F00491CA5;
productRefGroup = 694993CE1C8B334F00491CA5 /* Products */;
projectDirPath = "";
projectRoot = "";
targets = (
694993CC1C8B334F00491CA5 /* Sample */,
);
};
/* End PBXProject section */
/* Begin PBXResourcesBuildPhase section */
694993CB1C8B334F00491CA5 /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
694993E01C8B334F00491CA5 /* LaunchScreen.storyboard in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXResourcesBuildPhase section */
/* Begin PBXShellScriptBuildPhase section */
06EE2E0ABEB6289D4775A867 /* [CP] Copy Pods Resources */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "[CP] Copy Pods Resources";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-Sample/Pods-Sample-resources.sh\"\n";
showEnvVarsInLog = 0;
};
23FC03B282CBD9014D868DF6 /* [CP] Embed Pods Frameworks */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "[CP] Embed Pods Frameworks";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-Sample/Pods-Sample-frameworks.sh\"\n";
showEnvVarsInLog = 0;
};
339DA21AF893915BAA46F6A1 /* [CP] Check Pods Manifest.lock */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "[CP] 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;
};
/* End PBXShellScriptBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
694993C91C8B334F00491CA5 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
8092664B1DCD9CE1008373C2 /* OverviewCellNode.m in Sources */,
694993D81C8B334F00491CA5 /* OverviewViewController.m in Sources */,
694993D51C8B334F00491CA5 /* AppDelegate.m in Sources */,
694993D21C8B334F00491CA5 /* main.m in Sources */,
8032A2FF1DCD076E0083C469 /* LayoutExampleNodes.m in Sources */,
8032A2FC1DCD07580083C469 /* Utilities.m in Sources */,
8092664E1DCDA64A008373C2 /* LayoutExampleViewController.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */
/* Begin PBXVariantGroup section */
694993DE1C8B334F00491CA5 /* LaunchScreen.storyboard */ = {
isa = PBXVariantGroup;
children = (
694993DF1C8B334F00491CA5 /* Base */,
);
name = LaunchScreen.storyboard;
sourceTree = "<group>";
};
/* End PBXVariantGroup section */
/* Begin XCBuildConfiguration section */
694993E21C8B334F00491CA5 /* 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 = 7.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
};
name = Debug;
};
694993E31C8B334F00491CA5 /* 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 = 7.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
VALIDATE_PRODUCT = YES;
};
name = Release;
};
694993E51C8B334F00491CA5 /* Debug */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = C2FE4C0B2EE2F08E2186823E /* Pods-Sample.debug.xcconfig */;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
INFOPLIST_FILE = Sample/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = org.AsyncDisplayKit.Sample;
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Debug;
};
694993E61C8B334F00491CA5 /* Release */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 49ABEBD1ABCEC54CD6585C1B /* Pods-Sample.release.xcconfig */;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
INFOPLIST_FILE = Sample/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = org.AsyncDisplayKit.Sample;
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Release;
};
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
694993C81C8B334F00491CA5 /* Build configuration list for PBXProject "Sample" */ = {
isa = XCConfigurationList;
buildConfigurations = (
694993E21C8B334F00491CA5 /* Debug */,
694993E31C8B334F00491CA5 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
694993E41C8B334F00491CA5 /* Build configuration list for PBXNativeTarget "Sample" */ = {
isa = XCConfigurationList;
buildConfigurations = (
694993E51C8B334F00491CA5 /* Debug */,
694993E61C8B334F00491CA5 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
rootObject = 694993C51C8B334F00491CA5 /* Project object */;
}

View File

@@ -0,0 +1,91 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0810"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "694993CC1C8B334F00491CA5"
BuildableName = "Sample.app"
BlueprintName = "Sample"
ReferencedContainer = "container:Sample.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "694993CC1C8B334F00491CA5"
BuildableName = "Sample.app"
BlueprintName = "Sample"
ReferencedContainer = "container:Sample.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "694993CC1C8B334F00491CA5"
BuildableName = "Sample.app"
BlueprintName = "Sample"
ReferencedContainer = "container:Sample.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "694993CC1C8B334F00491CA5"
BuildableName = "Sample.app"
BlueprintName = "Sample"
ReferencedContainer = "container:Sample.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>

View File

@@ -0,0 +1,16 @@
//
// AppDelegate.h
// Sample
//
// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
// This source code is licensed under the BSD-style license found in the
// LICENSE file in the root directory of this source tree. An additional grant
// of patent rights can be found in the PATENTS file in the same directory.
//
#import <UIKit/UIKit.h>
@interface AppDelegate : UIResponder <UIApplicationDelegate>
@property (strong, nonatomic) UIWindow *window;
@end

View File

@@ -0,0 +1,30 @@
//
// AppDelegate.m
// Sample
//
// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
// This source code is licensed under the BSD-style license found in the
// LICENSE file in the root directory of this source tree. An additional grant
// of patent rights can be found in the PATENTS file in the same directory.
//
#import "AppDelegate.h"
#import "OverviewViewController.h"
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.window.backgroundColor = [UIColor whiteColor];
self.window.rootViewController = [[UINavigationController alloc] initWithRootViewController:[OverviewViewController new]];
[self.window makeKeyAndVisible];
[[UINavigationBar appearance] setBarTintColor:[UIColor colorWithRed:47/255.0 green:184/255.0 blue:253/255.0 alpha:1.0]];
[[UINavigationBar appearance] setTintColor:[UIColor whiteColor]];
[[UINavigationBar appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName : [UIColor whiteColor]}];;
return YES;
}
@end

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="10116" systemVersion="15F34" 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="10085"/>
</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,43 @@
<?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>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>armv7</string>
</array>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
</dict>
</plist>

View File

@@ -0,0 +1,28 @@
//
// LayoutExampleNodes.h
// Sample
//
// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
// This source code is licensed under the BSD-style license found in the
// LICENSE file in the root directory of this source tree. An additional grant
// of patent rights can be found in the PATENTS file in the same directory.
//
#import <AsyncDisplayKit/AsyncDisplayKit.h>
@interface LayoutExampleNode : ASDisplayNode
+ (NSString *)title;
+ (NSString *)descriptionTitle;
@end
@interface HeaderWithRightAndLeftItems : LayoutExampleNode
@end
@interface PhotoWithInsetTextOverlay : LayoutExampleNode
@end
@interface PhotoWithOutsetIconOverlay : LayoutExampleNode
@end
@interface FlexibleSeparatorSurroundingContent : LayoutExampleNode
@end

View File

@@ -0,0 +1,256 @@
//
// LayoutExampleNodes.m
// Sample
//
// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
// This source code is licensed under the BSD-style license found in the
// LICENSE file in the root directory of this source tree. An additional grant
// of patent rights can be found in the PATENTS file in the same directory.
//
#import "LayoutExampleNodes.h"
#import "Utilities.h"
#import "UIImage+ASConvenience.h"
@interface HeaderWithRightAndLeftItems ()
@property (nonatomic, strong) ASTextNode *usernameNode;
@property (nonatomic, strong) ASTextNode *postLocationNode;
@property (nonatomic, strong) ASTextNode *postTimeNode;
@end
@interface PhotoWithInsetTextOverlay ()
@property (nonatomic, strong) ASNetworkImageNode *photoNode;
@property (nonatomic, strong) ASTextNode *titleNode;
@end
@interface PhotoWithOutsetIconOverlay ()
@property (nonatomic, strong) ASNetworkImageNode *photoNode;
@property (nonatomic, strong) ASNetworkImageNode *iconNode;
@end
@interface FlexibleSeparatorSurroundingContent ()
@property (nonatomic, strong) ASImageNode *topSeparator;
@property (nonatomic, strong) ASImageNode *bottomSeparator;
@property (nonatomic, strong) ASTextNode *textNode;
@end
@implementation HeaderWithRightAndLeftItems
+ (NSString *)title
{
return @"Header with left and right justified text";
}
+ (NSString *)descriptionTitle
{
return @"try rotating me!";
}
- (instancetype)init
{
self = [super init];
if (self) {
_usernameNode = [[ASTextNode alloc] init];
_usernameNode.attributedText = [NSAttributedString attributedStringWithString:@"hannahmbanana"
fontSize:20
color:[UIColor darkBlueColor]];
_usernameNode.maximumNumberOfLines = 1;
_usernameNode.truncationMode = NSLineBreakByTruncatingTail;
_postLocationNode = [[ASTextNode alloc] init];
_postLocationNode.maximumNumberOfLines = 1;
_postLocationNode.attributedText = [NSAttributedString attributedStringWithString:@"Sunset Beach, San Fransisco, CA"
fontSize:20
color:[UIColor lightBlueColor]];
_postLocationNode.maximumNumberOfLines = 1;
_postLocationNode.truncationMode = NSLineBreakByTruncatingTail;
_postTimeNode = [[ASTextNode alloc] init];
_postTimeNode.attributedText = [NSAttributedString attributedStringWithString:@"30m"
fontSize:20
color:[UIColor lightGrayColor]];
_postLocationNode.maximumNumberOfLines = 1;
_postLocationNode.truncationMode = NSLineBreakByTruncatingTail;
}
return self;
}
@end
@implementation PhotoWithInsetTextOverlay
+ (NSString *)title
{
return @"Photo with inset text overlay";
}
+ (NSString *)descriptionTitle
{
return @"try rotating me!";
}
- (instancetype)init
{
self = [super init];
if (self) {
self.backgroundColor = [UIColor clearColor];
_photoNode = [[ASNetworkImageNode alloc] init];
_photoNode.URL = [NSURL URLWithString:@"http://asyncdisplaykit.org/static/images/layout-examples-photo-with-inset-text-overlay-photo.png"];
_photoNode.willDisplayNodeContentWithRenderingContext = ^(CGContextRef context) {
CGRect bounds = CGContextGetClipBoundingBox(context);
[[UIBezierPath bezierPathWithRoundedRect:bounds cornerRadius:10] addClip];
};
_titleNode = [[ASTextNode alloc] init];
_titleNode.maximumNumberOfLines = 2;
_titleNode.truncationMode = NSLineBreakByTruncatingTail;
_titleNode.truncationAttributedText = [NSAttributedString attributedStringWithString:@"..." fontSize:16 color:[UIColor whiteColor]];
_titleNode.attributedText = [NSAttributedString attributedStringWithString:@"family fall hikes" fontSize:16 color:[UIColor whiteColor]];
}
return self;
}
- (ASLayoutSpec *)layoutSpecThatFits:(ASSizeRange)constrainedSize
{
CGFloat photoDimension = constrainedSize.max.width / 4.0;
_photoNode.style.preferredSize = CGSizeMake(photoDimension, photoDimension);
// INFINITY is used to make the inset unbounded
UIEdgeInsets insets = UIEdgeInsetsMake(INFINITY, 12, 12, 12);
ASInsetLayoutSpec *textInsetSpec = [ASInsetLayoutSpec insetLayoutSpecWithInsets:insets child:_titleNode];
return [ASOverlayLayoutSpec overlayLayoutSpecWithChild:_photoNode overlay:textInsetSpec];;
}
@end
@implementation PhotoWithOutsetIconOverlay
+ (NSString *)title
{
return @"Photo with outset icon overlay";
}
- (instancetype)init
{
self = [super init];
if (self) {
_photoNode = [[ASNetworkImageNode alloc] init];
_photoNode.URL = [NSURL URLWithString:@"http://asyncdisplaykit.org/static/images/layout-examples-photo-with-outset-icon-overlay-photo.png"];
_iconNode = [[ASNetworkImageNode alloc] init];
_iconNode.URL = [NSURL URLWithString:@"http://asyncdisplaykit.org/static/images/layout-examples-photo-with-outset-icon-overlay-icon.png"];
[_iconNode setImageModificationBlock:^UIImage *(UIImage *image) { // FIXME: in framework autocomplete for setImageModificationBlock line seems broken
CGSize profileImageSize = CGSizeMake(60, 60);
return [image makeCircularImageWithSize:profileImageSize withBorderWidth:10];
}];
}
return self;
}
- (ASLayoutSpec *)layoutSpecThatFits:(ASSizeRange)constrainedSize
{
_iconNode.style.preferredSize = CGSizeMake(40, 40);
_iconNode.style.layoutPosition = CGPointMake(150, 0);
_photoNode.style.preferredSize = CGSizeMake(150, 150);
_photoNode.style.layoutPosition = CGPointMake(40 / 2.0, 40 / 2.0);
ASAbsoluteLayoutSpec *absoluteSpec = [ASAbsoluteLayoutSpec absoluteLayoutSpecWithChildren:@[_photoNode, _iconNode]];
// ASAbsoluteLayoutSpec's .sizing property recreates the behavior of ASDK Layout API 1.0's "ASStaticLayoutSpec"
absoluteSpec.sizing = ASAbsoluteLayoutSpecSizingSizeToFit;
return absoluteSpec;
}
@end
@implementation FlexibleSeparatorSurroundingContent
+ (NSString *)title
{
return @"Top and bottom cell separator lines";
}
+ (NSString *)descriptionTitle
{
return @"try rotating me!";
}
- (instancetype)init
{
self = [super init];
if (self) {
self.backgroundColor = [UIColor whiteColor];
_topSeparator = [[ASImageNode alloc] init];
_topSeparator.image = [UIImage as_resizableRoundedImageWithCornerRadius:1.0 cornerColor:[UIColor blackColor] fillColor:[UIColor blackColor]];
_textNode = [[ASTextNode alloc] init];
_textNode.attributedText = [NSAttributedString attributedStringWithString:@"this is a long text node"
fontSize:16
color:[UIColor blackColor]];
_bottomSeparator = [[ASImageNode alloc] init];
_bottomSeparator.image = [UIImage as_resizableRoundedImageWithCornerRadius:1.0 cornerColor:[UIColor blackColor] fillColor:[UIColor blackColor]];
}
return self;
}
- (ASLayoutSpec *)layoutSpecThatFits:(ASSizeRange)constrainedSize
{
_topSeparator.style.flexGrow = 1.0;
_bottomSeparator.style.flexGrow = 1.0;
_textNode.style.alignSelf = ASStackLayoutAlignSelfCenter;
ASStackLayoutSpec *verticalStackSpec = [ASStackLayoutSpec verticalStackLayoutSpec];
verticalStackSpec.spacing = 20;
verticalStackSpec.justifyContent = ASStackLayoutJustifyContentCenter;
verticalStackSpec.children = @[_topSeparator, _textNode, _bottomSeparator];
return [ASInsetLayoutSpec insetLayoutSpecWithInsets:UIEdgeInsetsMake(60, 0, 60, 0) child:verticalStackSpec];
}
@end
@implementation LayoutExampleNode
+ (NSString *)title
{
NSAssert(NO, @"All layout example nodes must provide a title!");
return nil;
}
+ (NSString *)descriptionTitle
{
return nil;
}
- (instancetype)init
{
self = [super init];
if (self) {
self.automaticallyManagesSubnodes = YES;
self.backgroundColor = [UIColor whiteColor];
}
return self;
}
@end

View File

@@ -0,0 +1,16 @@
//
// LayoutExampleViewController.h
// Sample
//
// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
// This source code is licensed under the BSD-style license found in the
// LICENSE file in the root directory of this source tree. An additional grant
// of patent rights can be found in the PATENTS file in the same directory.
//
#import <AsyncDisplayKit/AsyncDisplayKit.h>
@interface LayoutExampleViewController : ASViewController
- (instancetype)initWithLayoutExampleClass:(Class)layoutExampleClass NS_DESIGNATED_INITIALIZER;
- (instancetype)initWithNode:(ASDisplayNode *)node NS_UNAVAILABLE;
@end

View File

@@ -0,0 +1,48 @@
//
// LayoutExampleViewController.m
// Sample
//
// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
// This source code is licensed under the BSD-style license found in the
// LICENSE file in the root directory of this source tree. An additional grant
// of patent rights can be found in the PATENTS file in the same directory.
//
#import "LayoutExampleViewController.h"
#import "LayoutExampleNodes.h"
@interface LayoutExampleViewController ()
@property (nonatomic, strong) LayoutExampleNode *customNode;
@end
@implementation LayoutExampleViewController
- (instancetype)initWithLayoutExampleClass:(Class)layoutExampleClass
{
NSAssert([layoutExampleClass isSubclassOfClass:[LayoutExampleNode class]], @"Must pass a subclass of LayoutExampleNode.");
self = [super initWithNode:[ASDisplayNode new]];
if (self) {
self.title = @"Layout Example";
_customNode = [layoutExampleClass new];
[self.node addSubnode:_customNode];
BOOL needsOnlyYCentering = [layoutExampleClass isEqual:[HeaderWithRightAndLeftItems class]] ||
[layoutExampleClass isEqual:[FlexibleSeparatorSurroundingContent class]];
self.node.backgroundColor = needsOnlyYCentering ? [UIColor lightGrayColor] : [UIColor whiteColor];
__weak __typeof(self) weakself = self;
self.node.layoutSpecBlock = ^ASLayoutSpec*(__kindof ASDisplayNode * _Nonnull node, ASSizeRange constrainedSize) {
return [ASCenterLayoutSpec centerLayoutSpecWithCenteringOptions:needsOnlyYCentering ? ASCenterLayoutSpecCenteringY : ASCenterLayoutSpecCenteringXY
sizingOptions:ASCenterLayoutSpecSizingOptionMinimumXY
child:weakself.customNode];
};
}
return self;
}
@end

View File

@@ -0,0 +1,20 @@
//
// OverviewCellNode.h
// Sample
//
// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
// This source code is licensed under the BSD-style license found in the
// LICENSE file in the root directory of this source tree. An additional grant
// of patent rights can be found in the PATENTS file in the same directory.
//
#import <AsyncDisplayKit/AsyncDisplayKit.h>
@interface OverviewCellNode : ASCellNode
@property (nonatomic, strong) Class layoutExampleClass;
- (instancetype)initWithLayoutExampleClass:(Class)layoutExampleClass NS_DESIGNATED_INITIALIZER;
- (instancetype)init NS_UNAVAILABLE;
@end

View File

@@ -0,0 +1,53 @@
//
// OverviewCellNode.m
// Sample
//
// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
// This source code is licensed under the BSD-style license found in the
// LICENSE file in the root directory of this source tree. An additional grant
// of patent rights can be found in the PATENTS file in the same directory.
//
#import "OverviewCellNode.h"
#import "LayoutExampleNodes.h"
#import "Utilities.h"
@interface OverviewCellNode ()
@property (nonatomic, strong) ASTextNode *titleNode;
@property (nonatomic, strong) ASTextNode *descriptionNode;
@end
@implementation OverviewCellNode
- (instancetype)initWithLayoutExampleClass:(Class)layoutExampleClass
{
self = [super init];
if (self) {
self.automaticallyManagesSubnodes = YES;
_layoutExampleClass = layoutExampleClass;
_titleNode = [[ASTextNode alloc] init];
_titleNode.attributedText = [NSAttributedString attributedStringWithString:[layoutExampleClass title]
fontSize:16
color:[UIColor blackColor]];
_descriptionNode = [[ASTextNode alloc] init];
_descriptionNode.attributedText = [NSAttributedString attributedStringWithString:[layoutExampleClass descriptionTitle]
fontSize:12
color:[UIColor lightGrayColor]];
}
return self;
}
- (ASLayoutSpec *)layoutSpecThatFits:(ASSizeRange)constrainedSize
{
ASStackLayoutSpec *verticalStackSpec = [ASStackLayoutSpec verticalStackLayoutSpec];
verticalStackSpec.alignItems = ASStackLayoutAlignItemsStart;
verticalStackSpec.spacing = 5.0;
verticalStackSpec.children = @[self.titleNode, self.descriptionNode];
return [ASInsetLayoutSpec insetLayoutSpecWithInsets:UIEdgeInsetsMake(10, 16, 10, 10) child:verticalStackSpec];
}
@end

View File

@@ -0,0 +1,16 @@
//
// OverviewViewController.h
// Sample
//
// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
// This source code is licensed under the BSD-style license found in the
// LICENSE file in the root directory of this source tree. An additional grant
// of patent rights can be found in the PATENTS file in the same directory.
//
#import <AsyncDisplayKit/AsyncDisplayKit.h>
@interface OverviewViewController : ASViewController
@end

View File

@@ -0,0 +1,75 @@
//
// OverviewViewController.m
// Sample
//
// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
// This source code is licensed under the BSD-style license found in the
// LICENSE file in the root directory of this source tree. An additional grant
// of patent rights can be found in the PATENTS file in the same directory.
//
#import "OverviewViewController.h"
#import "LayoutExampleNodes.h"
#import "LayoutExampleViewController.h"
#import "OverviewCellNode.h"
@interface OverviewViewController () <ASTableDelegate, ASTableDataSource>
@property (nonatomic, strong) NSArray *layoutExamples;
@property (nonatomic, strong) ASTableNode *tableNode;
@end
@implementation OverviewViewController
#pragma mark - Lifecycle Methods
- (instancetype)init
{
_tableNode = [ASTableNode new];
self = [super initWithNode:_tableNode];
if (self) {
self.title = @"Layout Examples";
self.navigationItem.backBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"" style:UIBarButtonItemStylePlain target:nil action:nil];
_tableNode.delegate = self;
_tableNode.dataSource = self;
_layoutExamples = @[[HeaderWithRightAndLeftItems class],
[PhotoWithInsetTextOverlay class],
[PhotoWithOutsetIconOverlay class],
[FlexibleSeparatorSurroundingContent class]];
}
return self;
}
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
NSIndexPath *indexPath = _tableNode.indexPathForSelectedRow;
if (indexPath != nil) {
[_tableNode deselectRowAtIndexPath:indexPath animated:YES];
}
}
#pragma mark - ASTableDelegate, ASTableDataSource
- (NSInteger)tableNode:(ASTableNode *)tableNode numberOfRowsInSection:(NSInteger)section
{
return [_layoutExamples count];
}
- (ASCellNode *)tableNode:(ASTableNode *)tableNode nodeForRowAtIndexPath:(NSIndexPath *)indexPath
{
return [[OverviewCellNode alloc] initWithLayoutExampleClass:_layoutExamples[indexPath.row]];
}
- (void)tableNode:(ASTableNode *)tableNode didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
Class layoutExampleClass = [[tableNode nodeForRowAtIndexPath:indexPath] layoutExampleClass];
LayoutExampleViewController *detail = [[LayoutExampleViewController alloc] initWithLayoutExampleClass:layoutExampleClass];
[self.navigationController pushViewController:detail animated:YES];
}
@end

View File

@@ -0,0 +1,25 @@
//
// Utilities.h
// Sample
//
// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
// This source code is licensed under the BSD-style license found in the
// LICENSE file in the root directory of this source tree. An additional grant
// of patent rights can be found in the PATENTS file in the same directory.
//
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
@interface UIColor (Additions)
+ (UIColor *)darkBlueColor;
+ (UIColor *)lightBlueColor;
@end
@interface UIImage (Additions)
- (UIImage *)makeCircularImageWithSize:(CGSize)size withBorderWidth:(CGFloat)width;
@end
@interface NSAttributedString (Additions)
+ (NSAttributedString *)attributedStringWithString:(NSString *)string fontSize:(CGFloat)size color:(UIColor *)color;
@end

View File

@@ -0,0 +1,85 @@
//
// Utilities.m
// Sample
//
// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
// This source code is licensed under the BSD-style license found in the
// LICENSE file in the root directory of this source tree. An additional grant
// of patent rights can be found in the PATENTS file in the same directory.
//
#import "Utilities.h"
#define StrokeRoundedImages 0
@implementation UIColor (Additions)
+ (UIColor *)darkBlueColor
{
return [UIColor colorWithRed:18.0/255.0 green:86.0/255.0 blue:136.0/255.0 alpha:1.0];
}
+ (UIColor *)lightBlueColor
{
return [UIColor colorWithRed:0.0 green:122.0/255.0 blue:1.0 alpha:1.0];
}
@end
@implementation UIImage (Additions)
- (UIImage *)makeCircularImageWithSize:(CGSize)size withBorderWidth:(CGFloat)width
{
// make a CGRect with the image's size
CGRect circleRect = (CGRect) {CGPointZero, size};
// begin the image context since we're not in a drawRect:
UIGraphicsBeginImageContextWithOptions(circleRect.size, NO, 0);
// create a UIBezierPath circle
UIBezierPath *circle = [UIBezierPath bezierPathWithRoundedRect:circleRect cornerRadius:circleRect.size.width/2];
// clip to the circle
[circle addClip];
[[UIColor whiteColor] set];
[circle fill];
// draw the image in the circleRect *AFTER* the context is clipped
[self drawInRect:circleRect];
// create a border (for white background pictures)
if (width > 0) {
circle.lineWidth = width;
[[UIColor whiteColor] set];
[circle stroke];
}
// get an image from the image context
UIImage *roundedImage = UIGraphicsGetImageFromCurrentImageContext();
// end the image context since we're not in a drawRect:
UIGraphicsEndImageContext();
return roundedImage;
}
@end
@implementation NSAttributedString (Additions)
+ (NSAttributedString *)attributedStringWithString:(NSString *)string fontSize:(CGFloat)size color:(nullable UIColor *)color
{
if (string == nil) {
return nil;
}
NSDictionary *attributes = @{NSForegroundColorAttributeName: color ? : [UIColor blackColor],
NSFontAttributeName: [UIFont boldSystemFontOfSize:size]};
NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:string];
[attributedString addAttributes:attributes range:NSMakeRange(0, string.length)];
return attributedString;
}
@end

View File

@@ -0,0 +1,25 @@
//
// main.m
// Sample
//
// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
// This source code is licensed under the BSD-style license found in the
// LICENSE file in the root directory of this source tree. An additional grant
// of patent rights can be found in the PATENTS file in the same directory.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// FACEBOOK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
// ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
#import <UIKit/UIKit.h>
#import "AppDelegate.h"
int main(int argc, char * argv[]) {
@autoreleasepool {
return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
}
}