Skip to content

Commit

Permalink
Merge pull request #194 from dev-0/swift2.3
Browse files Browse the repository at this point in the history
Swift2.3
  • Loading branch information
AnthonyMDev authored Oct 10, 2016
2 parents 5575c4b + adfef4d commit 4095efd
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 17 deletions.
16 changes: 13 additions & 3 deletions DKCamera/DKCamera.swift
Original file line number Diff line number Diff line change
Expand Up @@ -290,11 +290,21 @@ public class DKCamera: UIViewController {

let outputRect = self.previewLayer.metadataOutputRectOfInterestForRect(self.previewLayer.bounds)
let takenCGImage = takenImage.CGImage
let width = CGFloat(CGImageGetWidth(takenCGImage))
let height = CGFloat(CGImageGetHeight(takenCGImage))
#if swift(>=2.3)
let width = CGFloat(CGImageGetWidth(takenCGImage!))
let height = CGFloat(CGImageGetHeight(takenCGImage!))
#else
let width = CGFloat(CGImageGetWidth(takenCGImage))
let height = CGFloat(CGImageGetHeight(takenCGImage))
#endif
let cropRect = CGRectMake(outputRect.origin.x * width, outputRect.origin.y * height, outputRect.size.width * width, outputRect.size.height * height)

let cropCGImage = CGImageCreateWithImageInRect(takenCGImage, cropRect)
#if swift(>=2.3)
let cropCGImage = CGImageCreateWithImageInRect(takenCGImage!, cropRect)
#else
let cropCGImage = CGImageCreateWithImageInRect(takenCGImage, cropRect)
#endif

let cropTakenImage = UIImage(CGImage: cropCGImage!, scale: 1, orientation: takenImage.imageOrientation)

didFinishCapturingImage(image: cropTakenImage)
Expand Down
30 changes: 23 additions & 7 deletions DKImagePickerController/DKPopoverViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -76,24 +76,40 @@ public class DKPopoverViewController: UIViewController {

let context = UIGraphicsGetCurrentContext()
UIColor.clearColor().setFill()
CGContextFillRect(context, CGRect(x: 0, y: 0, width: arrowWidth, height: arrowHeight))

#if swift(>=2.3)
CGContextFillRect(context!, CGRect(x: 0, y: 0, width: arrowWidth, height: arrowHeight))
#else
CGContextFillRect(context, CGRect(x: 0, y: 0, width: arrowWidth, height: arrowHeight))
#endif

let arrowPath = CGPathCreateMutable()

CGPathMoveToPoint(arrowPath, nil, arrowWidth / 2, 0)
CGPathAddLineToPoint(arrowPath, nil, arrowWidth, arrowHeight)
CGPathAddLineToPoint(arrowPath, nil, 0, arrowHeight)
CGPathCloseSubpath(arrowPath)

CGContextAddPath(context, arrowPath)

CGContextSetFillColorWithColor(context, UIColor.whiteColor().CGColor)
CGContextDrawPath(context, CGPathDrawingMode.Fill)
#if swift(>=2.3)
CGContextAddPath(context!, arrowPath)

CGContextSetFillColorWithColor(context!, UIColor.whiteColor().CGColor)
CGContextDrawPath(context!, CGPathDrawingMode.Fill)
#else
CGContextAddPath(context, arrowPath)

CGContextSetFillColorWithColor(context, UIColor.whiteColor().CGColor)
CGContextDrawPath(context, CGPathDrawingMode.Fill)
#endif


let arrowImage = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()

return arrowImage
#if swift(>=2.3)
return arrowImage!
#else
return arrowImage
#endif
}
}

Expand Down
31 changes: 26 additions & 5 deletions DKImagePickerControllerDemo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -417,21 +417,25 @@
attributes = {
LastSwiftMigration = 0700;
LastSwiftUpdateCheck = 0730;
LastUpgradeCheck = 0730;
LastUpgradeCheck = 0800;
ORGANIZATIONNAME = ZhangAo;
TargetAttributes = {
9C35CBFE19DBB00700557269 = {
CreatedOnToolsVersion = 6.0;
LastSwiftMigration = 0800;
};
9CF72B101B8F073400238B9A = {
CreatedOnToolsVersion = 6.4;
LastSwiftMigration = 0800;
TestTargetID = 9C35CBFE19DBB00700557269;
};
B9EFB9621D20FB7D006CDCAA = {
CreatedOnToolsVersion = 7.3.1;
LastSwiftMigration = 0800;
};
B9EFB96B1D20FB7D006CDCAA = {
CreatedOnToolsVersion = 7.3.1;
LastSwiftMigration = 0800;
TestTargetID = 9C35CBFE19DBB00700557269;
};
};
Expand Down Expand Up @@ -623,6 +627,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
Expand All @@ -632,8 +637,10 @@
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
Expand All @@ -642,6 +649,7 @@
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",
Expand All @@ -666,6 +674,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
Expand All @@ -675,15 +684,18 @@
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = YES;
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;
Expand All @@ -693,42 +705,45 @@
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
VALIDATE_PRODUCT = YES;
};
name = Release;
};
9C35CC1F19DBB00700557269 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage;
CODE_SIGN_IDENTITY = "iPhone Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
EMBEDDED_CONTENT_CONTAINS_SWIFT = YES;
INFOPLIST_FILE = DKImagePickerControllerDemo/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.DKImagePickerControllerDemo;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE = "";
SWIFT_VERSION = 2.3;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
};
9C35CC2019DBB00700557269 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage;
CODE_SIGN_IDENTITY = "iPhone Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
EMBEDDED_CONTENT_CONTAINS_SWIFT = YES;
INFOPLIST_FILE = DKImagePickerControllerDemo/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.DKImagePickerControllerDemo;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE = "";
SWIFT_VERSION = 2.3;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Release;
Expand All @@ -749,6 +764,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "com.zhangao.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 2.3;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/DKImagePickerControllerDemo.app/DKImagePickerControllerDemo";
};
name = Debug;
Expand All @@ -766,6 +782,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "com.zhangao.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 2.3;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/DKImagePickerControllerDemo.app/DKImagePickerControllerDemo";
};
name = Release;
Expand All @@ -775,7 +792,7 @@
buildSettings = {
CLANG_ANALYZER_NONNULL = YES;
CODE_SIGN_IDENTITY = "iPhone Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "";
CURRENT_PROJECT_VERSION = 1;
DEBUG_INFORMATION_FORMAT = dwarf;
DEFINES_MODULE = YES;
Expand All @@ -790,6 +807,7 @@
PRODUCT_BUNDLE_IDENTIFIER = com.DKImagePickerController.DKImagePickerController;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_VERSION = 2.3;
TARGETED_DEVICE_FAMILY = "1,2";
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
Expand All @@ -801,7 +819,7 @@
buildSettings = {
CLANG_ANALYZER_NONNULL = YES;
CODE_SIGN_IDENTITY = "iPhone Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "";
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 1;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
Expand All @@ -817,6 +835,7 @@
PRODUCT_BUNDLE_IDENTIFIER = com.DKImagePickerController.DKImagePickerController;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_VERSION = 2.3;
TARGETED_DEVICE_FAMILY = "1,2";
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
Expand All @@ -834,6 +853,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.DKImagePickerController.DKImagePickerControllerTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 2.3;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/DKImagePickerControllerDemo.app/DKImagePickerControllerDemo";
};
name = Debug;
Expand All @@ -850,6 +870,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.DKImagePickerController.DKImagePickerControllerTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 2.3;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/DKImagePickerControllerDemo.app/DKImagePickerControllerDemo";
};
name = Release;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0730"
LastUpgradeVersion = "0800"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0730"
LastUpgradeVersion = "0800"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down

0 comments on commit 4095efd

Please sign in to comment.