diff --git a/SegmentedControl.xcodeproj/project.pbxproj b/SegmentedControl.xcodeproj/project.pbxproj index 0e27468..5035b8a 100644 --- a/SegmentedControl.xcodeproj/project.pbxproj +++ b/SegmentedControl.xcodeproj/project.pbxproj @@ -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; }; }; }; @@ -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; @@ -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; @@ -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; }; @@ -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; }; diff --git a/SegmentedControl.xcodeproj/xcshareddata/xcschemes/SegmentedControl.xcscheme b/SegmentedControl.xcodeproj/xcshareddata/xcschemes/SegmentedControl.xcscheme index a0e0ee1..ab56cdc 100644 --- a/SegmentedControl.xcodeproj/xcshareddata/xcschemes/SegmentedControl.xcscheme +++ b/SegmentedControl.xcodeproj/xcshareddata/xcschemes/SegmentedControl.xcscheme @@ -1,6 +1,6 @@ @@ -36,6 +37,7 @@ buildConfiguration = "Debug" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" + language = "" launchStyle = "0" useCustomWorkingDirectory = "NO" ignoresPersistentStateOnLaunch = "NO" diff --git a/SegmentedControl/SegmentedControl.swift b/SegmentedControl/SegmentedControl.swift index 2d95280..8c57128 100644 --- a/SegmentedControl/SegmentedControl.swift +++ b/SegmentedControl/SegmentedControl.swift @@ -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!") diff --git a/SegmentedControl/Supporting Files/Info.plist b/SegmentedControl/Supporting Files/Info.plist index 587b5df..bc568f7 100644 --- a/SegmentedControl/Supporting Files/Info.plist +++ b/SegmentedControl/Supporting Files/Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 0.0.7 + 0.0.8 CFBundleSignature ???? CFBundleVersion diff --git a/SegmentedControlExample.xcodeproj/project.pbxproj b/SegmentedControlExample.xcodeproj/project.pbxproj index d8ecede..e540b4a 100644 --- a/SegmentedControlExample.xcodeproj/project.pbxproj +++ b/SegmentedControlExample.xcodeproj/project.pbxproj @@ -108,12 +108,12 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 0720; - LastUpgradeCheck = 0800; + LastUpgradeCheck = 0900; ORGANIZATIONNAME = Teambition; TargetAttributes = { D3E3B0DE1C328316003EAA6E = { CreatedOnToolsVersion = 7.2; - LastSwiftMigration = 0800; + LastSwiftMigration = 0900; }; }; }; @@ -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; @@ -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; @@ -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; }; @@ -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; }; diff --git a/SegmentedControlExample.xcodeproj/xcuserdata/hongxin.xcuserdatad/xcschemes/SegmentedControlExample.xcscheme b/SegmentedControlExample.xcodeproj/xcuserdata/hongxin.xcuserdatad/xcschemes/SegmentedControlExample.xcscheme index cf4d33f..e187895 100644 --- a/SegmentedControlExample.xcodeproj/xcuserdata/hongxin.xcuserdatad/xcschemes/SegmentedControlExample.xcscheme +++ b/SegmentedControlExample.xcodeproj/xcuserdata/hongxin.xcuserdatad/xcschemes/SegmentedControlExample.xcscheme @@ -1,6 +1,6 @@ @@ -45,6 +46,7 @@ buildConfiguration = "Debug" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" + language = "" launchStyle = "0" useCustomWorkingDirectory = "NO" ignoresPersistentStateOnLaunch = "NO" diff --git a/SegmentedControlExample/ExampleViewController.swift b/SegmentedControlExample/ExampleViewController.swift index 07475ff..9bff4b9 100644 --- a/SegmentedControlExample/ExampleViewController.swift +++ b/SegmentedControlExample/ExampleViewController.swift @@ -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) @@ -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) @@ -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) @@ -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) @@ -91,7 +91,7 @@ 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) } @@ -99,7 +99,7 @@ class ExampleViewController: UIViewController { 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) @@ -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) @@ -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) @@ -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) diff --git a/SegmentedControlExample/Info.plist b/SegmentedControlExample/Info.plist index a052c5a..44dfdc5 100644 --- a/SegmentedControlExample/Info.plist +++ b/SegmentedControlExample/Info.plist @@ -15,11 +15,11 @@ CFBundlePackageType APPL CFBundleShortVersionString - 0.0.7 + 0.0.8 CFBundleSignature ???? CFBundleVersion - 7 + 8 LSRequiresIPhoneOS UILaunchStoryboardName