commit b4d60474ee0f5864c32975fe8c7834babcf56d20 Author: Zhigang Fang Date: Sat May 28 10:27:12 2016 +0800 Initial Commit diff --git a/Readme.md b/Readme.md new file mode 100644 index 0000000..e69de29 diff --git a/Slides.playground/Contents.swift b/Slides.playground/Contents.swift new file mode 100644 index 0000000..02707f6 --- /dev/null +++ b/Slides.playground/Contents.swift @@ -0,0 +1,3 @@ +import Slides + +Slides.Title("Slides".uppercaseString, subtitle: "Build Keynot In Your Playground").render() \ No newline at end of file diff --git a/Slides.playground/contents.xcplayground b/Slides.playground/contents.xcplayground new file mode 100644 index 0000000..5da2641 --- /dev/null +++ b/Slides.playground/contents.xcplayground @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/Slides.playground/timeline.xctimeline b/Slides.playground/timeline.xctimeline new file mode 100644 index 0000000..2c23da2 --- /dev/null +++ b/Slides.playground/timeline.xctimeline @@ -0,0 +1,12 @@ + + + + + + + diff --git a/Slides.xcodeproj/project.pbxproj b/Slides.xcodeproj/project.pbxproj new file mode 100644 index 0000000..c62864c --- /dev/null +++ b/Slides.xcodeproj/project.pbxproj @@ -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 = ""; }; + 043C79BF1CF9396A0092E6C4 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 043C79C51CF9398D0092E6C4 /* Slides.playground */ = {isa = PBXFileReference; lastKnownFileType = file.playground; path = Slides.playground; sourceTree = ""; }; + 043C79C61CF939C40092E6C4 /* Slides.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Slides.swift; sourceTree = ""; }; + 043C79C81CF93A610092E6C4 /* Modifiable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Modifiable.swift; sourceTree = ""; }; + 043C79CA1CF93AA70092E6C4 /* Functions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Functions.swift; sourceTree = ""; }; + 043C79CC1CF93E020092E6C4 /* UIKitFunctions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UIKitFunctions.swift; sourceTree = ""; }; +/* 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 = ""; + }; + 043C79BB1CF9396A0092E6C4 /* Products */ = { + isa = PBXGroup; + children = ( + 043C79BA1CF9396A0092E6C4 /* Slides.framework */, + ); + name = Products; + sourceTree = ""; + }; + 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 = ""; + }; +/* 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 */; +} diff --git a/Slides.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/Slides.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..87c6dc9 --- /dev/null +++ b/Slides.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/Slides.xcodeproj/project.xcworkspace/xcuserdata/kylefang.xcuserdatad/UserInterfaceState.xcuserstate b/Slides.xcodeproj/project.xcworkspace/xcuserdata/kylefang.xcuserdatad/UserInterfaceState.xcuserstate new file mode 100644 index 0000000..a7e1a4b Binary files /dev/null and b/Slides.xcodeproj/project.xcworkspace/xcuserdata/kylefang.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/Slides.xcodeproj/xcuserdata/kylefang.xcuserdatad/xcschemes/Slides.xcscheme b/Slides.xcodeproj/xcuserdata/kylefang.xcuserdatad/xcschemes/Slides.xcscheme new file mode 100644 index 0000000..3af98f1 --- /dev/null +++ b/Slides.xcodeproj/xcuserdata/kylefang.xcuserdatad/xcschemes/Slides.xcscheme @@ -0,0 +1,80 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Slides.xcodeproj/xcuserdata/kylefang.xcuserdatad/xcschemes/xcschememanagement.plist b/Slides.xcodeproj/xcuserdata/kylefang.xcuserdatad/xcschemes/xcschememanagement.plist new file mode 100644 index 0000000..bc3959d --- /dev/null +++ b/Slides.xcodeproj/xcuserdata/kylefang.xcuserdatad/xcschemes/xcschememanagement.plist @@ -0,0 +1,22 @@ + + + + + SchemeUserState + + Slides.xcscheme + + orderHint + 0 + + + SuppressBuildableAutocreation + + 043C79B91CF9396A0092E6C4 + + primary + + + + + diff --git a/Slides/Functions.swift b/Slides/Functions.swift new file mode 100644 index 0000000..8936749 --- /dev/null +++ b/Slides/Functions.swift @@ -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 |> (l: A, r: A -> B) -> B { + return r(l) +} + +func |> (l: A->B, r: B->C) -> A-> C { + return { a in + r(l(a)) + } +} \ No newline at end of file diff --git a/Slides/Info.plist b/Slides/Info.plist new file mode 100644 index 0000000..d3de8ee --- /dev/null +++ b/Slides/Info.plist @@ -0,0 +1,26 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + FMWK + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + $(CURRENT_PROJECT_VERSION) + NSPrincipalClass + + + diff --git a/Slides/Modifiable.swift b/Slides/Modifiable.swift new file mode 100644 index 0000000..85b343b --- /dev/null +++ b/Slides/Modifiable.swift @@ -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 {} \ No newline at end of file diff --git a/Slides/Slides.h b/Slides/Slides.h new file mode 100644 index 0000000..244fcb5 --- /dev/null +++ b/Slides/Slides.h @@ -0,0 +1,19 @@ +// +// Slides.h +// Slides +// +// Created by Kyle Fang on 5/28/16. +// Copyright © 2016 Kyle Fang. All rights reserved. +// + +#import + +//! 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 + + diff --git a/Slides/Slides.swift b/Slides/Slides.swift new file mode 100644 index 0000000..c48558e --- /dev/null +++ b/Slides/Slides.swift @@ -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 + } +} diff --git a/Slides/UIKitFunctions.swift b/Slides/UIKitFunctions.swift new file mode 100644 index 0000000..886a1e0 --- /dev/null +++ b/Slides/UIKitFunctions.swift @@ -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(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) \ No newline at end of file diff --git a/screenshot.png b/screenshot.png new file mode 100644 index 0000000..c9622d9 Binary files /dev/null and b/screenshot.png differ