Skip to content

Commit

Permalink
support Xcode 10.0
Browse files Browse the repository at this point in the history
  • Loading branch information
hongxinhope committed Sep 26, 2018
1 parent 715076c commit 38400d1
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 34 deletions.
4 changes: 2 additions & 2 deletions SegmentedControl.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
};
name = Debug;
};
Expand All @@ -308,7 +308,7 @@
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
};
name = Release;
};
Expand Down
6 changes: 3 additions & 3 deletions SegmentedControl/SegmentedControl.swift
Original file line number Diff line number Diff line change
Expand Up @@ -496,11 +496,11 @@ public extension SegmentedControl {
let titleLayer: CATextLayer = {
let titleLayer = CATextLayer()
titleLayer.frame = titleRect
titleLayer.alignmentMode = kCAAlignmentCenter
titleLayer.alignmentMode = .center
if #available(iOS 10.0, *) {
titleLayer.truncationMode = kCATruncationNone
titleLayer.truncationMode = .none
} else {
titleLayer.truncationMode = kCATruncationEnd
titleLayer.truncationMode = .end
}
titleLayer.string = titleString
titleLayer.contentsScale = UIScreen.main.scale
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.9</string>
<string>0.1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
Expand Down
4 changes: 2 additions & 2 deletions SegmentedControlExample.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@
PRODUCT_BUNDLE_IDENTIFIER = Teambition.SegmentedControlExample;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
};
name = Debug;
};
Expand All @@ -297,7 +297,7 @@
PRODUCT_BUNDLE_IDENTIFIER = Teambition.SegmentedControlExample;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
};
name = Release;
};
Expand Down
20 changes: 6 additions & 14 deletions SegmentedControlExample/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,37 +10,29 @@ import UIKit

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

var window: UIWindow?


func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil) -> Bool {
return true
}

func applicationWillResignActive(_ application: UIApplication) {
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.

}

func applicationDidEnterBackground(_ application: UIApplication) {
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.

}

func applicationWillEnterForeground(_ application: UIApplication) {
// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.

}

func applicationDidBecomeActive(_ application: UIApplication) {
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}

func applicationWillTerminate(_ application: UIApplication) {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}

func applicationWillTerminate(_ application: UIApplication) {

}
}

20 changes: 10 additions & 10 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: [NSAttributedStringKey: Any] = [.font: UIFont.systemFont(ofSize: 17), .foregroundColor: UIColor.darkGray]
let attributes: [NSAttributedString.Key: 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: [NSAttributedStringKey: Any] = [.font: UIFont.systemFont(ofSize: 17), .foregroundColor: UIColor.white]
let attributes: [NSAttributedString.Key: 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 @@ -51,7 +51,7 @@ class ExampleViewController: UIViewController {
}()
let segmentedControl = SegmentedControl.initWithTitles(titles, selectedTitles: selectedTitles)
segmentedControl.delegate = self
segmentedControl.backgroundColor = UIColor.clear
segmentedControl.backgroundColor = .clear
segmentedControl.selectionBoxColor = kLivelyBlueColor
segmentedControl.selectionBoxStyle = .default
segmentedControl.selectionBoxCornerRadius = 15
Expand All @@ -66,7 +66,7 @@ class ExampleViewController: UIViewController {
fileprivate func configureNavigationBelowSegmentedControl() {
let titleStrings = ["任务", "分享", "文件", "日程", "账目", "标签", "通知", "聊天", "收件箱", "联系人"]
let titles: [NSAttributedString] = {
let attributes: [NSAttributedStringKey: Any] = [.font: UIFont.systemFont(ofSize: 16), .foregroundColor: UIColor.black]
let attributes: [NSAttributedString.Key: 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: [NSAttributedStringKey: Any] = [.font: UIFont.systemFont(ofSize: 16), .foregroundColor: kLivelyBlueColor]
let attributes: [NSAttributedString.Key: Any] = [.font: UIFont.systemFont(ofSize: 16), .foregroundColor: kLivelyBlueColor]
var selectedTitles = [NSAttributedString]()
for titleString in titleStrings {
let selectedTitle = NSAttributedString(string: titleString, attributes: attributes)
Expand All @@ -85,7 +85,7 @@ class ExampleViewController: UIViewController {
}()
let segmentedControl = SegmentedControl.initWithTitles(titles, selectedTitles: selectedTitles)
segmentedControl.delegate = self
segmentedControl.backgroundColor = UIColor.white
segmentedControl.backgroundColor = .white
segmentedControl.autoresizingMask = [.flexibleRightMargin, .flexibleWidth]
segmentedControl.selectionIndicatorStyle = .bottom
segmentedControl.selectionIndicatorColor = kLivelyBlueColor
Expand All @@ -99,7 +99,7 @@ class ExampleViewController: UIViewController {
fileprivate func configureSegmentedControl1() {
let titleStrings = ["任务", "分享", "文件", "日程", "聊天"]
let titles: [NSAttributedString] = {
let attributes: [NSAttributedStringKey: Any] = [.font: UIFont.systemFont(ofSize: 17), .foregroundColor: UIColor.white]
let attributes: [NSAttributedString.Key: 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: [NSAttributedStringKey: Any] = [.font: UIFont.systemFont(ofSize: 17), .foregroundColor: UIColor(white: 0.1, alpha: 1)]
let attributes: [NSAttributedString.Key: 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: [NSAttributedStringKey: Any] = [.font: UIFont.systemFont(ofSize: 17), .foregroundColor: UIColor.darkGray]
let attributes: [NSAttributedString.Key: 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: [NSAttributedStringKey: Any] = [.font: UIFont.systemFont(ofSize: 17), .foregroundColor: UIColor.white]
let attributes: [NSAttributedString.Key: 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.9</string>
<string>0.1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>9</string>
<string>10</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UILaunchStoryboardName</key>
Expand Down

0 comments on commit 38400d1

Please sign in to comment.