Initial Commit

This commit is contained in:
Zhigang Fang
2016-05-28 10:27:12 +08:00
commit b4d60474ee
16 changed files with 669 additions and 0 deletions

0
Readme.md Normal file
View File

View File

@@ -0,0 +1,3 @@
import Slides
Slides.Title("Slides".uppercaseString, subtitle: "Build Keynot In Your Playground").render()

View File

@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<playground version='5.0' target-platform='ios'>
<timeline fileName='timeline.xctimeline'/>
</playground>

View File

@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<Timeline
version = "3.0">
<TimelineItems>
<LoggerValueHistoryTimelineItem
documentLocation = "#CharacterRangeLen=91&amp;CharacterRangeLoc=16&amp;EndingColumnNumber=77&amp;EndingLineNumber=2&amp;StartingColumnNumber=1&amp;StartingLineNumber=2&amp;Timestamp=486096967.557278"
lockedSize = "{737.5, 548}"
selectedRepresentationIndex = "0"
shouldTrackSuperviewWidth = "NO">
</LoggerValueHistoryTimelineItem>
</TimelineItems>
</Timeline>

View File

@@ -0,0 +1,306 @@
// !$*UTF8*$!
{
archiveVersion = 1;
classes = {
};
objectVersion = 46;
objects = {
/* Begin PBXBuildFile section */
043C79BE1CF9396A0092E6C4 /* Slides.h in Headers */ = {isa = PBXBuildFile; fileRef = 043C79BD1CF9396A0092E6C4 /* Slides.h */; settings = {ATTRIBUTES = (Public, ); }; };
043C79C71CF939C40092E6C4 /* Slides.swift in Sources */ = {isa = PBXBuildFile; fileRef = 043C79C61CF939C40092E6C4 /* Slides.swift */; };
043C79C91CF93A610092E6C4 /* Modifiable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 043C79C81CF93A610092E6C4 /* Modifiable.swift */; };
043C79CB1CF93AA70092E6C4 /* Functions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 043C79CA1CF93AA70092E6C4 /* Functions.swift */; };
043C79CD1CF93E020092E6C4 /* UIKitFunctions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 043C79CC1CF93E020092E6C4 /* UIKitFunctions.swift */; };
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
043C79BA1CF9396A0092E6C4 /* Slides.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Slides.framework; sourceTree = BUILT_PRODUCTS_DIR; };
043C79BD1CF9396A0092E6C4 /* Slides.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Slides.h; sourceTree = "<group>"; };
043C79BF1CF9396A0092E6C4 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
043C79C51CF9398D0092E6C4 /* Slides.playground */ = {isa = PBXFileReference; lastKnownFileType = file.playground; path = Slides.playground; sourceTree = "<group>"; };
043C79C61CF939C40092E6C4 /* Slides.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Slides.swift; sourceTree = "<group>"; };
043C79C81CF93A610092E6C4 /* Modifiable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Modifiable.swift; sourceTree = "<group>"; };
043C79CA1CF93AA70092E6C4 /* Functions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Functions.swift; sourceTree = "<group>"; };
043C79CC1CF93E020092E6C4 /* UIKitFunctions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UIKitFunctions.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
043C79B61CF9396A0092E6C4 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
043C79B01CF9396A0092E6C4 = {
isa = PBXGroup;
children = (
043C79C51CF9398D0092E6C4 /* Slides.playground */,
043C79BC1CF9396A0092E6C4 /* Slides */,
043C79BB1CF9396A0092E6C4 /* Products */,
);
sourceTree = "<group>";
};
043C79BB1CF9396A0092E6C4 /* Products */ = {
isa = PBXGroup;
children = (
043C79BA1CF9396A0092E6C4 /* Slides.framework */,
);
name = Products;
sourceTree = "<group>";
};
043C79BC1CF9396A0092E6C4 /* Slides */ = {
isa = PBXGroup;
children = (
043C79BD1CF9396A0092E6C4 /* Slides.h */,
043C79BF1CF9396A0092E6C4 /* Info.plist */,
043C79C61CF939C40092E6C4 /* Slides.swift */,
043C79C81CF93A610092E6C4 /* Modifiable.swift */,
043C79CA1CF93AA70092E6C4 /* Functions.swift */,
043C79CC1CF93E020092E6C4 /* UIKitFunctions.swift */,
);
path = Slides;
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXHeadersBuildPhase section */
043C79B71CF9396A0092E6C4 /* Headers */ = {
isa = PBXHeadersBuildPhase;
buildActionMask = 2147483647;
files = (
043C79BE1CF9396A0092E6C4 /* Slides.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXHeadersBuildPhase section */
/* Begin PBXNativeTarget section */
043C79B91CF9396A0092E6C4 /* Slides */ = {
isa = PBXNativeTarget;
buildConfigurationList = 043C79C21CF9396A0092E6C4 /* Build configuration list for PBXNativeTarget "Slides" */;
buildPhases = (
043C79B51CF9396A0092E6C4 /* Sources */,
043C79B61CF9396A0092E6C4 /* Frameworks */,
043C79B71CF9396A0092E6C4 /* Headers */,
043C79B81CF9396A0092E6C4 /* Resources */,
);
buildRules = (
);
dependencies = (
);
name = Slides;
productName = Slides;
productReference = 043C79BA1CF9396A0092E6C4 /* Slides.framework */;
productType = "com.apple.product-type.framework";
};
/* End PBXNativeTarget section */
/* Begin PBXProject section */
043C79B11CF9396A0092E6C4 /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0730;
ORGANIZATIONNAME = "Kyle Fang";
TargetAttributes = {
043C79B91CF9396A0092E6C4 = {
CreatedOnToolsVersion = 7.3.1;
};
};
};
buildConfigurationList = 043C79B41CF9396A0092E6C4 /* Build configuration list for PBXProject "Slides" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
hasScannedForEncodings = 0;
knownRegions = (
en,
);
mainGroup = 043C79B01CF9396A0092E6C4;
productRefGroup = 043C79BB1CF9396A0092E6C4 /* Products */;
projectDirPath = "";
projectRoot = "";
targets = (
043C79B91CF9396A0092E6C4 /* Slides */,
);
};
/* End PBXProject section */
/* Begin PBXResourcesBuildPhase section */
043C79B81CF9396A0092E6C4 /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXResourcesBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
043C79B51CF9396A0092E6C4 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
043C79C71CF939C40092E6C4 /* Slides.swift in Sources */,
043C79C91CF93A610092E6C4 /* Modifiable.swift in Sources */,
043C79CD1CF93E020092E6C4 /* UIKitFunctions.swift in Sources */,
043C79CB1CF93AA70092E6C4 /* Functions.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */
/* Begin XCBuildConfiguration section */
043C79C01CF9396A0092E6C4 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_NONNULL = YES;
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;
CURRENT_PROJECT_VERSION = 1;
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.3;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
TARGETED_DEVICE_FAMILY = "1,2";
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
};
name = Debug;
};
043C79C11CF9396A0092E6C4 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_NONNULL = YES;
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;
CURRENT_PROJECT_VERSION = 1;
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.3;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
TARGETED_DEVICE_FAMILY = "1,2";
VALIDATE_PRODUCT = YES;
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
};
name = Release;
};
043C79C31CF9396A0092E6C4 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
CLANG_ENABLE_MODULES = YES;
DEFINES_MODULE = YES;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath";
INFOPLIST_FILE = Slides/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.matrix.Slides;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
};
name = Debug;
};
043C79C41CF9396A0092E6C4 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
CLANG_ENABLE_MODULES = YES;
DEFINES_MODULE = YES;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath";
INFOPLIST_FILE = Slides/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.matrix.Slides;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
};
name = Release;
};
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
043C79B41CF9396A0092E6C4 /* Build configuration list for PBXProject "Slides" */ = {
isa = XCConfigurationList;
buildConfigurations = (
043C79C01CF9396A0092E6C4 /* Debug */,
043C79C11CF9396A0092E6C4 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
043C79C21CF9396A0092E6C4 /* Build configuration list for PBXNativeTarget "Slides" */ = {
isa = XCConfigurationList;
buildConfigurations = (
043C79C31CF9396A0092E6C4 /* Debug */,
043C79C41CF9396A0092E6C4 /* Release */,
);
defaultConfigurationIsVisible = 0;
};
/* End XCConfigurationList section */
};
rootObject = 043C79B11CF9396A0092E6C4 /* Project object */;
}

View File

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

View File

@@ -0,0 +1,80 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0730"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "043C79B91CF9396A0092E6C4"
BuildableName = "Slides.framework"
BlueprintName = "Slides"
ReferencedContainer = "container:Slides.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
<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">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "043C79B91CF9396A0092E6C4"
BuildableName = "Slides.framework"
BlueprintName = "Slides"
ReferencedContainer = "container:Slides.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "043C79B91CF9396A0092E6C4"
BuildableName = "Slides.framework"
BlueprintName = "Slides"
ReferencedContainer = "container:Slides.xcodeproj">
</BuildableReference>
</MacroExpansion>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>

View File

@@ -0,0 +1,22 @@
<?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>SchemeUserState</key>
<dict>
<key>Slides.xcscheme</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
</dict>
</dict>
<key>SuppressBuildableAutocreation</key>
<dict>
<key>043C79B91CF9396A0092E6C4</key>
<dict>
<key>primary</key>
<true/>
</dict>
</dict>
</dict>
</plist>

20
Slides/Functions.swift Normal file
View File

@@ -0,0 +1,20 @@
//
// Functions.swift
// Slides
//
// Created by Kyle Fang on 5/28/16.
// Copyright © 2016 Kyle Fang. All rights reserved.
//
import UIKit
infix operator |> { associativity left precedence 110 }
func |> <A, B> (l: A, r: A -> B) -> B {
return r(l)
}
func |> <A, B, C> (l: A->B, r: B->C) -> A-> C {
return { a in
r(l(a))
}
}

26
Slides/Info.plist Normal file
View File

@@ -0,0 +1,26 @@
<?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>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>NSPrincipalClass</key>
<string></string>
</dict>
</plist>

22
Slides/Modifiable.swift Normal file
View File

@@ -0,0 +1,22 @@
//
// Modifiable.swift
// Slides
//
// Created by Kyle Fang on 5/28/16.
// Copyright © 2016 Kyle Fang. All rights reserved.
//
import Foundation
protocol Modifiable: class {}
extension Modifiable {
static func modify(modification: Self -> Void) -> Self -> Self {
return { instance in
modification(instance)
return instance
}
}
}
extension NSObject: Modifiable {}

19
Slides/Slides.h Normal file
View File

@@ -0,0 +1,19 @@
//
// Slides.h
// Slides
//
// Created by Kyle Fang on 5/28/16.
// Copyright © 2016 Kyle Fang. All rights reserved.
//
#import <UIKit/UIKit.h>
//! Project version number for Slides.
FOUNDATION_EXPORT double SlidesVersionNumber;
//! Project version string for Slides.
FOUNDATION_EXPORT const unsigned char SlidesVersionString[];
// In this header, you should import all the public headers of your framework using statements like #import <Slides/PublicHeader.h>

93
Slides/Slides.swift Normal file
View File

@@ -0,0 +1,93 @@
private let slideSize = CGSize(width: 1024, height: 768)
let titleLabelStyle = useTextColor(UIColor(0x34A5DA))
|> useFont(.boldSystemFontOfSize(150))
|> useAdjustsFontSizeToFitWidth(true)
let subtitleLabelStyle = useTextColor(UIColor(0xA6AAA9))
|> useFont(.systemFontOfSize(45))
|> useAdjustsFontSizeToFitWidth(true)
let listTitleStyle = useTextColor(UIColor(0x34A5DA))
|> useFont(.boldSystemFontOfSize(56))
let listContentStyle = useTextColor(UIColor(0x838787))
|> useFont(.systemFontOfSize(34))
public struct Slides {
public let render: () -> UIView
public static func Title(text: String) -> Slides {
return Slides {
let view = master()
view.addSubview(
UILabel(frame: CGRect(x: 44, y: 250, width: 940, height: 150))
|> titleLabelStyle
|> useTitle(text)
)
return view
}
}
public static func Title(text:String, subtitle: String) -> Slides {
return Slides {
let view = master()
view.addSubview(
UILabel(frame: CGRect(x: 40, y: 508, width: 940, height: 150))
|> titleLabelStyle
|> useTitle(text)
)
view.addSubview(
UIView(frame: CGRect(x: 30, y: 480, width: 960, height: 3))
|> useBackgroundColor(UIColor(0xA6AAA9))
)
view.addSubview(
UILabel(frame: CGRect(x: 40, y: 420, width: 940, height: 56))
|> subtitleLabelStyle
|> useTitle(subtitle)
)
return view
}
}
public static func Image(image: UIImage) -> Slides {
return Slides {
let imageView = UIImageView()
|> useImage(image)
|> useContentMode(.ScaleAspectFit)
imageView.sizeToFit()
return imageView
}
}
public static func Image(image: String) -> Slides {
return self.Image(UIImage(named: image)!)
}
public static func List(title: String, items: [String]) -> Slides {
return Slides {
let view = master()
view.addSubview(
UIView(frame: CGRect(x: 30, y: 78, width: 960, height: 3))
|> useBackgroundColor(UIColor(0xA6AAA9))
)
view.addSubview(
UILabel(frame: CGRect(x: 30, y: 122, width: 960, height: 60))
|> useTitle(title)
|> listTitleStyle
)
let itemsText = items.map({"\($0)"}).joinWithSeparator("\n\n")
view.addSubview(
UILabel(frame: CGRect(x: 30, y: 208, width: 960, height: 500))
|> useTitle(itemsText)
|> listContentStyle
|> useMultipleLines
)
return view
}
}
}
extension Slides {
static func master() -> UIView {
let container = UIView(frame: CGRect(origin: .zero, size: slideSize))
container.backgroundColor = UIColor(0x222222)
return container
}
}

View File

@@ -0,0 +1,55 @@
//
// UIKitFunctions.swift
// Slides
//
// Created by Kyle Fang on 5/28/16.
// Copyright © 2016 Kyle Fang. All rights reserved.
//
import Foundation
extension UIColor {
convenience public init(_ hex: Int, alpha: CGFloat = 1.0) {
let red = CGFloat((hex & 0xFF0000) >> 16) / 255.0
let green = CGFloat((hex & 0xFF00) >> 8) / 255.0
let blue = CGFloat((hex & 0xFF)) / 255.0
self.init(red:red, green:green, blue:blue, alpha:alpha)
}
}
func useTitle(text: String) -> UILabel -> UILabel {
return UILabel.modify { $0.text = text }
}
func useFont(font: UIFont) -> UILabel -> UILabel {
return UILabel.modify { $0.font = font }
}
func useTextColor(color: UIColor) -> UILabel -> UILabel {
return UILabel.modify { $0.textColor = color }
}
func useAdjustsFontSizeToFitWidth(adjustsFontSizeToFitWidth: Bool) -> UILabel -> UILabel {
return UILabel.modify { $0.adjustsFontSizeToFitWidth = adjustsFontSizeToFitWidth }
}
func useContentMode<T: UIView>(cm: UIViewContentMode) -> T -> T {
return {
$0.contentMode = cm
return $0
}
}
func useImage(image: UIImage) -> UIImageView -> UIImageView {
return UIImageView.modify {$0.image = image}
}
func useBackgroundColor(color: UIColor ) -> UIView -> UIView {
return UIView.modify { $0.backgroundColor = color }
}
func useLines(lines: Int) -> UILabel -> UILabel {
return UILabel.modify { $0.numberOfLines = lines }
}
let useMultipleLines = useLines(0)

BIN
screenshot.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 423 KiB