Skip to content

Commit

Permalink
Merge branch 'swift4'
Browse files Browse the repository at this point in the history
  • Loading branch information
hongxinhope committed Sep 26, 2017
2 parents 3b87e30 + 98e7427 commit 5b544e5
Show file tree
Hide file tree
Showing 8 changed files with 55 additions and 23 deletions.
22 changes: 18 additions & 4 deletions SegmentedControl.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,12 @@
D3E3B0C21C3282BB003EAA6E /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0800;
LastUpgradeCheck = 0900;
ORGANIZATIONNAME = Teambition;
TargetAttributes = {
D3E3B0CA1C3282BB003EAA6E = {
CreatedOnToolsVersion = 7.2;
LastSwiftMigration = 0800;
LastSwiftMigration = 0900;
};
};
};
Expand Down Expand Up @@ -169,14 +169,20 @@
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = 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_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
Expand Down Expand Up @@ -219,14 +225,20 @@
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = 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_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
Expand Down Expand Up @@ -271,7 +283,8 @@
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 3.0;
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.0;
};
name = Debug;
};
Expand All @@ -290,7 +303,8 @@
PRODUCT_BUNDLE_IDENTIFIER = Teambition.SegmentedControl;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_VERSION = 3.0;
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.0;
};
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 = "0800"
LastUpgradeVersion = "0900"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand All @@ -26,6 +26,7 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
Expand All @@ -36,6 +37,7 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
Expand Down
2 changes: 1 addition & 1 deletion SegmentedControl/SegmentedControl.swift
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ extension SegmentedControl: UIGestureRecognizerDelegate {
return false
}

func segmentedControlLongPressed(_ gesture: UIGestureRecognizer) {
@objc func segmentedControlLongPressed(_ gesture: UIGestureRecognizer) {
switch gesture.state {
case .possible:
print("LongPressGesture Possible!")
Expand Down
2 changes: 1 addition & 1 deletion SegmentedControl/Supporting Files/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>0.0.7</string>
<string>0.0.8</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
Expand Down
22 changes: 18 additions & 4 deletions SegmentedControlExample.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,12 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0720;
LastUpgradeCheck = 0800;
LastUpgradeCheck = 0900;
ORGANIZATIONNAME = Teambition;
TargetAttributes = {
D3E3B0DE1C328316003EAA6E = {
CreatedOnToolsVersion = 7.2;
LastSwiftMigration = 0800;
LastSwiftMigration = 0900;
};
};
};
Expand Down Expand Up @@ -179,14 +179,20 @@
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = 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_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
Expand Down Expand Up @@ -226,14 +232,20 @@
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = 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_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
Expand Down Expand Up @@ -267,7 +279,8 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = Teambition.SegmentedControlExample;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.0;
};
name = Debug;
};
Expand All @@ -279,7 +292,8 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = Teambition.SegmentedControlExample;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.0;
};
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 = "0800"
LastUpgradeVersion = "0900"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand All @@ -26,6 +26,7 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
Expand All @@ -45,6 +46,7 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
Expand Down
18 changes: 9 additions & 9 deletions SegmentedControlExample/ExampleViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class ExampleViewController: UIViewController {
fileprivate func configureNavigationTitleSegmentedControl() {
let titleStrings = ["任务", "分享", "文件", "日程"]
let titles: [NSAttributedString] = {
let attributes = [NSFontAttributeName: UIFont.systemFont(ofSize: 17), NSForegroundColorAttributeName: UIColor.darkGray]
let attributes: [NSAttributedStringKey: Any] = [.font: UIFont.systemFont(ofSize: 17), .foregroundColor: UIColor.darkGray]
var titles = [NSAttributedString]()
for titleString in titleStrings {
let title = NSAttributedString(string: titleString, attributes: attributes)
Expand All @@ -41,7 +41,7 @@ class ExampleViewController: UIViewController {
return titles
}()
let selectedTitles: [NSAttributedString] = {
let attributes = [NSFontAttributeName: UIFont.systemFont(ofSize: 17), NSForegroundColorAttributeName: UIColor.white]
let attributes: [NSAttributedStringKey: Any] = [.font: UIFont.systemFont(ofSize: 17), .foregroundColor: UIColor.white]
var selectedTitles = [NSAttributedString]()
for titleString in titleStrings {
let selectedTitle = NSAttributedString(string: titleString, attributes: attributes)
Expand All @@ -66,7 +66,7 @@ class ExampleViewController: UIViewController {
fileprivate func configureNavigationBelowSegmentedControl() {
let titleStrings = ["任务", "分享", "文件", "日程", "账目", "标签", "通知", "聊天", "收件箱", "联系人"]
let titles: [NSAttributedString] = {
let attributes = [NSFontAttributeName: UIFont.systemFont(ofSize: 16), NSForegroundColorAttributeName: UIColor.black]
let attributes: [NSAttributedStringKey: Any] = [.font: UIFont.systemFont(ofSize: 16), .foregroundColor: UIColor.black]
var titles = [NSAttributedString]()
for titleString in titleStrings {
let title = NSAttributedString(string: titleString, attributes: attributes)
Expand All @@ -75,7 +75,7 @@ class ExampleViewController: UIViewController {
return titles
}()
let selectedTitles: [NSAttributedString] = {
let attributes = [NSFontAttributeName: UIFont.systemFont(ofSize: 16), NSForegroundColorAttributeName: kLivelyBlueColor]
let attributes: [NSAttributedStringKey: Any] = [.font: UIFont.systemFont(ofSize: 16), .foregroundColor: kLivelyBlueColor]
var selectedTitles = [NSAttributedString]()
for titleString in titleStrings {
let selectedTitle = NSAttributedString(string: titleString, attributes: attributes)
Expand All @@ -91,15 +91,15 @@ class ExampleViewController: UIViewController {
segmentedControl.selectionIndicatorColor = kLivelyBlueColor
segmentedControl.selectionIndicatorHeight = 3
segmentedControl.segmentWidth = 65
segmentedControl.frame.origin.y = 64
segmentedControl.frame.origin.y = UIApplication.shared.statusBarFrame.height + 44
segmentedControl.frame.size = CGSize(width: UIScreen.main.bounds.width, height: 40)
view.insertSubview(segmentedControl, belowSubview: navigationController!.navigationBar)
}

fileprivate func configureSegmentedControl1() {
let titleStrings = ["任务", "分享", "文件", "日程", "聊天"]
let titles: [NSAttributedString] = {
let attributes = [NSFontAttributeName: UIFont.systemFont(ofSize: 17), NSForegroundColorAttributeName: UIColor.white]
let attributes: [NSAttributedStringKey: Any] = [.font: UIFont.systemFont(ofSize: 17), .foregroundColor: UIColor.white]
var titles = [NSAttributedString]()
for titleString in titleStrings {
let title = NSAttributedString(string: titleString, attributes: attributes)
Expand All @@ -108,7 +108,7 @@ class ExampleViewController: UIViewController {
return titles
}()
let selectedTitles: [NSAttributedString] = {
let attributes = [NSFontAttributeName: UIFont.systemFont(ofSize: 17), NSForegroundColorAttributeName: UIColor(white: 0.1, alpha: 1)]
let attributes: [NSAttributedStringKey: Any] = [.font: UIFont.systemFont(ofSize: 17), .foregroundColor: UIColor(white: 0.1, alpha: 1)]
var selectedTitles = [NSAttributedString]()
for titleString in titleStrings {
let selectedTitle = NSAttributedString(string: titleString, attributes: attributes)
Expand Down Expand Up @@ -139,7 +139,7 @@ class ExampleViewController: UIViewController {
fileprivate func configureSegmentedControl3() {
let titleStrings = ["Tasks", "Posts", "Files", "Meetings", "Favourites", "Chats"]
let titles: [NSAttributedString] = {
let attributes = [NSFontAttributeName: UIFont.systemFont(ofSize: 17), NSForegroundColorAttributeName: UIColor.darkGray]
let attributes: [NSAttributedStringKey: Any] = [.font: UIFont.systemFont(ofSize: 17), .foregroundColor: UIColor.darkGray]
var titles = [NSAttributedString]()
for titleString in titleStrings {
let title = NSAttributedString(string: titleString, attributes: attributes)
Expand All @@ -148,7 +148,7 @@ class ExampleViewController: UIViewController {
return titles
}()
let selectedTitles: [NSAttributedString] = {
let attributes = [NSFontAttributeName: UIFont.systemFont(ofSize: 17), NSForegroundColorAttributeName: UIColor.white]
let attributes: [NSAttributedStringKey: Any] = [.font: UIFont.systemFont(ofSize: 17), .foregroundColor: UIColor.white]
var selectedTitles = [NSAttributedString]()
for titleString in titleStrings {
let selectedTitle = NSAttributedString(string: titleString, attributes: attributes)
Expand Down
4 changes: 2 additions & 2 deletions SegmentedControlExample/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>0.0.7</string>
<string>0.0.8</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>7</string>
<string>8</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UILaunchStoryboardName</key>
Expand Down

0 comments on commit 5b544e5

Please sign in to comment.