Skip to content

Commit a0cdc83

Browse files
committed
1、升级至Swift5.0;
2、更新Demo路径;
1 parent eb7aa87 commit a0cdc83

211 files changed

Lines changed: 19 additions & 2296 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

FWSegmentedControl/FWSegmentedControl.podspec renamed to FWSegmentedControl.podspec

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Pod::Spec.new do |s|
1616
#
1717

1818
s.name = "FWSegmentedControl"
19-
s.version = "2.2.0"
19+
s.version = "2.3.0"
2020
s.summary = "滑动分段控制,多样式、灵活、便利是其最大的优势。"
2121

2222
# This description is used to generate tags and improve search results.
@@ -64,8 +64,7 @@ Pod::Spec.new do |s|
6464
# the deployment target. You can optionally include the target after the platform.
6565
#
6666

67-
s.swift_version = "4.0"
68-
s.platform = :ios
67+
s.swift_version = "5.0"
6968
s.platform = :ios, "8.0"
7069

7170
# When using multiple platforms
@@ -92,7 +91,7 @@ Pod::Spec.new do |s|
9291
# Not including the public_header_files will make all headers public.
9392
#
9493

95-
s.source_files = "FWSegmentedControl/FWSegmentedControl/FWSegmentedControl/*.swift"
94+
s.source_files = "FWSegmentedControl", "FWSegmentedControl/**/*.swift"
9695

9796
# s.exclude_files = "Classes/Exclude"
9897
# s.public_header_files = "Classes/**/*.h"
@@ -119,7 +118,7 @@ Pod::Spec.new do |s|
119118
#
120119

121120
# s.framework = "SomeFramework"
122-
# s.frameworks = "SomeFramework", "AnotherFramework"
121+
s.frameworks = "UIKit", "Foundation"
123122

124123
# s.library = "iconv"
125124
# s.libraries = "iconv", "xml2"
@@ -131,7 +130,7 @@ Pod::Spec.new do |s|
131130
# where they will only apply to your library. If you depend on other Podspecs
132131
# you can include multiple dependencies to ensure it works.
133132

134-
# s.requires_arc = true
133+
s.requires_arc = true
135134

136135
# s.xcconfig = { "HEADER_SEARCH_PATHS" => "$(SDKROOT)/usr/include/libxml2" }
137136
# s.dependency "JSONKit", "~> 1.4"

FWSegmentedControl_OC/Pods/FWSegmentedControl/FWSegmentedControl/FWSegmentedControl/FWSegmentedControl/FWSegmentedControl.swift renamed to FWSegmentedControl/FWSegmentedControl.swift

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -221,9 +221,9 @@ open class FWSegmentedControl: UIControl {
221221
@objc public var enlargetouchesEdgeInset = UIEdgeInsets.zero
222222

223223
/// 未选中的标题属性
224-
@objc public var titleTextAttributes: [NSAttributedStringKey: Any]?
224+
@objc public var titleTextAttributes: [NSAttributedString.Key: Any]?
225225
/// 选中的标题属性
226-
@objc public var selectedTitleTextAttributes: [NSAttributedStringKey: Any]?
226+
@objc public var selectedTitleTextAttributes: [NSAttributedString.Key: Any]?
227227

228228
/// 是否可以拖动
229229
@objc public var userDraggable = true
@@ -584,9 +584,9 @@ extension FWSegmentedControl {
584584
if self.scType == .text {
585585
let titleLayer = CATextLayer()
586586
titleLayer.frame = contentRect
587-
titleLayer.alignmentMode = kCAAlignmentCenter
587+
titleLayer.alignmentMode = CATextLayerAlignmentMode.center
588588
if (UIDevice.current.systemVersion as NSString).doubleValue < 10.0 {
589-
titleLayer.truncationMode = kCATruncationEnd
589+
titleLayer.truncationMode = CATextLayerTruncationMode.end
590590
}
591591
titleLayer.string = self.attributedTitleAtIndex(index: index)
592592
titleLayer.contentsScale = UIScreen.main.scale
@@ -646,9 +646,9 @@ extension FWSegmentedControl {
646646
titleRect = CGRect(x: contentRect.origin.x, y: contentRect.origin.y + (contentRect.height - strSize.height) / 2, width: strSize.width, height: strSize.height)
647647
}
648648
titleLayer.frame = titleRect
649-
titleLayer.alignmentMode = kCAAlignmentCenter
649+
titleLayer.alignmentMode = CATextLayerAlignmentMode.center
650650
if (UIDevice.current.systemVersion as NSString).doubleValue < 10.0 {
651-
titleLayer.truncationMode = kCATruncationEnd
651+
titleLayer.truncationMode = CATextLayerTruncationMode.end
652652
}
653653
titleLayer.string = self.attributedTitleAtIndex(index: index)
654654
titleLayer.contentsScale = UIScreen.main.scale
@@ -841,7 +841,7 @@ extension FWSegmentedControl {
841841

842842
CATransaction.begin()
843843
CATransaction.setAnimationDuration(indicatorAnimatedTimes)
844-
CATransaction.setAnimationTimingFunction(CAMediaTimingFunction(name: kCAMediaTimingFunctionLinear))
844+
CATransaction.setAnimationTimingFunction(CAMediaTimingFunction(name: CAMediaTimingFunctionName.linear))
845845
if self.scSelectionIndicatorStyle == .arrowUp || self.scSelectionIndicatorStyle == .arrowDown {
846846
self.setArrowFrame()
847847
} else if self.scSelectionIndicatorStyle == .box {
@@ -1174,7 +1174,7 @@ extension FWSegmentedControl {
11741174
/// 选中segment的文字属性
11751175
///
11761176
/// - Returns: 文字属性
1177-
fileprivate func resultingSelectedTitleTextAttributes() -> [NSAttributedStringKey: Any] {
1177+
fileprivate func resultingSelectedTitleTextAttributes() -> [NSAttributedString.Key: Any] {
11781178

11791179
var resultingAttrs = self.resultingTitleTextAttributes()
11801180
if self.selectedTitleTextAttributes != nil {
@@ -1186,11 +1186,11 @@ extension FWSegmentedControl {
11861186
/// 未选中segment的文字属性
11871187
///
11881188
/// - Returns: 文字属性
1189-
fileprivate func resultingTitleTextAttributes() -> [NSAttributedStringKey: Any] {
1189+
fileprivate func resultingTitleTextAttributes() -> [NSAttributedString.Key: Any] {
11901190

1191-
var defaults = [NSAttributedStringKey.foregroundColor: UIColor.black, NSAttributedStringKey.font : UIFont.systemFont(ofSize: CGFloat(16.0))]
1191+
var defaults = [NSAttributedString.Key.foregroundColor: UIColor.black, NSAttributedString.Key.font : UIFont.systemFont(ofSize: CGFloat(16.0))]
11921192
if self.titleTextAttributes != nil {
1193-
defaults = self.titleTextAttributes! as! [NSAttributedStringKey : NSObject]
1193+
defaults = self.titleTextAttributes! as! [NSAttributedString.Key : NSObject]
11941194
}
11951195
return defaults
11961196
}
@@ -1205,10 +1205,10 @@ extension FWSegmentedControl {
12051205
return self.titleFormatterBlock!(self, title, index, selected)
12061206
} else {
12071207
var titleAttrs = selected ? self.resultingSelectedTitleTextAttributes() : self.resultingTitleTextAttributes()
1208-
let titleColor = titleAttrs[NSAttributedStringKey.foregroundColor] as? UIColor
1208+
let titleColor = titleAttrs[NSAttributedString.Key.foregroundColor] as? UIColor
12091209
if titleColor != nil {
12101210
var dict = titleAttrs
1211-
dict[NSAttributedStringKey.foregroundColor] = titleColor?.cgColor
1211+
dict[NSAttributedString.Key.foregroundColor] = titleColor?.cgColor
12121212
titleAttrs = dict
12131213
}
12141214
return NSAttributedString(string: title, attributes: titleAttrs)
@@ -1266,3 +1266,4 @@ open class FWSectionImageItem: NSObject {
12661266
super.init()
12671267
}
12681268
}
1269+

0 commit comments

Comments
 (0)