Skip to content

Commit 8180249

Browse files
committed
优化别名, 防止冲突
1 parent 555c2c1 commit 8180249

7 files changed

Lines changed: 37 additions & 50 deletions

File tree

AttributedString.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Pod::Spec.new do |s|
22

33
s.name = "AttributedString"
4-
s.version = "3.3.2"
4+
s.version = "3.3.3"
55
s.summary = "基于Swift字符串插值快速构建你想要的富文本, 支持点击按住等事件获取, 支持多种类型过滤"
66

77
s.homepage = "https://github.com/lixiang1994/AttributedString"

Demo-Watch/Demo-Watch.xcodeproj/xcshareddata/xcschemes/Demo-Watch WatchKit App.xcscheme

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -54,46 +54,33 @@
5454
debugDocumentVersioning = "YES"
5555
debugServiceExtension = "internal"
5656
allowLocationSimulation = "YES">
57-
<RemoteRunnable
58-
runnableDebuggingMode = "2"
59-
BundleIdentifier = "com.apple.Carousel"
60-
RemotePath = "/Demo-Watch WatchKit App">
57+
<BuildableProductRunnable
58+
runnableDebuggingMode = "0">
6159
<BuildableReference
6260
BuildableIdentifier = "primary"
6361
BlueprintIdentifier = "9B267B4D24405CFA002F571E"
6462
BuildableName = "Demo-Watch WatchKit App.app"
6563
BlueprintName = "Demo-Watch WatchKit App"
6664
ReferencedContainer = "container:Demo-Watch.xcodeproj">
6765
</BuildableReference>
68-
</RemoteRunnable>
66+
</BuildableProductRunnable>
6967
</LaunchAction>
7068
<ProfileAction
7169
buildConfiguration = "Release"
7270
shouldUseLaunchSchemeArgsEnv = "YES"
7371
savedToolIdentifier = ""
7472
useCustomWorkingDirectory = "NO"
7573
debugDocumentVersioning = "YES">
76-
<RemoteRunnable
77-
runnableDebuggingMode = "2"
78-
BundleIdentifier = "com.apple.Carousel"
79-
RemotePath = "/Demo-Watch WatchKit App">
74+
<BuildableProductRunnable
75+
runnableDebuggingMode = "0">
8076
<BuildableReference
8177
BuildableIdentifier = "primary"
8278
BlueprintIdentifier = "9B267B4D24405CFA002F571E"
8379
BuildableName = "Demo-Watch WatchKit App.app"
8480
BlueprintName = "Demo-Watch WatchKit App"
8581
ReferencedContainer = "container:Demo-Watch.xcodeproj">
8682
</BuildableReference>
87-
</RemoteRunnable>
88-
<MacroExpansion>
89-
<BuildableReference
90-
BuildableIdentifier = "primary"
91-
BlueprintIdentifier = "9B267B4D24405CFA002F571E"
92-
BuildableName = "Demo-Watch WatchKit App.app"
93-
BlueprintName = "Demo-Watch WatchKit App"
94-
ReferencedContainer = "container:Demo-Watch.xcodeproj">
95-
</BuildableReference>
96-
</MacroExpansion>
83+
</BuildableProductRunnable>
9784
</ProfileAction>
9885
<AnalyzeAction
9986
buildConfiguration = "Debug">

Sources/Action.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -189,22 +189,22 @@ extension ASAttributedStringInterpolation {
189189

190190
extension ASAttributedString.Action.Highlight {
191191

192-
public static func foreground(_ value: Color) -> Self {
192+
public static func foreground(_ value: ASColor) -> Self {
193193
return .init(attributes: [.foregroundColor: value])
194194
}
195195

196-
public static func background(_ value: Color) -> Self {
196+
public static func background(_ value: ASColor) -> Self {
197197
return .init(attributes: [.backgroundColor: value])
198198
}
199199

200-
public static func strikethrough(_ style: NSUnderlineStyle, color: Color? = nil) -> Self {
200+
public static func strikethrough(_ style: NSUnderlineStyle, color: ASColor? = nil) -> Self {
201201
var temp: [NSAttributedString.Key: Any] = [:]
202202
temp[.strikethroughColor] = color
203203
temp[.strikethroughStyle] = style.rawValue
204204
return .init(attributes: temp)
205205
}
206206

207-
public static func underline(_ style: NSUnderlineStyle, color: Color? = nil) -> Self {
207+
public static func underline(_ style: NSUnderlineStyle, color: ASColor? = nil) -> Self {
208208
var temp: [NSAttributedString.Key: Any] = [:]
209209
temp[.underlineColor] = color
210210
temp[.underlineStyle] = style.rawValue
@@ -215,7 +215,7 @@ extension ASAttributedString.Action.Highlight {
215215
return .init(attributes: [.shadow: value])
216216
}
217217

218-
public static func stroke(_ width: CGFloat = 0, color: Color? = nil) -> Self {
218+
public static func stroke(_ width: CGFloat = 0, color: ASColor? = nil) -> Self {
219219
var temp: [NSAttributedString.Key: Any] = [:]
220220
temp[.strokeColor] = color
221221
temp[.strokeWidth] = width

Sources/Attachment.swift

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import UIKit
2222
extension ASAttributedString {
2323

2424
public enum Attachment {
25-
case image(Image, bounds: CGRect)
25+
case image(ASImage, bounds: CGRect)
2626
case data(Data, type: String)
2727
case file(FileWrapper)
2828
case attachment(NSTextAttachment)
@@ -55,11 +55,11 @@ extension ASAttributedString {
5555

5656
public let style: Style
5757

58-
public static func image(_ image: Image, _ style: Style = .original()) -> ImageAttachment {
58+
public static func image(_ image: ASImage, _ style: Style = .original()) -> ImageAttachment {
5959
return .init(image, style)
6060
}
6161

62-
init(_ image: Image?, _ style: Style = .original()) {
62+
init(_ image: ASImage?, _ style: Style = .original()) {
6363
self.style = style
6464
super.init(data: nil, ofType: nil)
6565
self.image = image
@@ -110,7 +110,7 @@ extension ASAttributedString {
110110
public static var Loader: AsyncImageAttachmentLoader.Type = AsyncImageAttachmentURLSessionLoader.self
111111

112112
public let url: URL?
113-
public let placeholder: Image?
113+
public let placeholder: ASImage?
114114

115115
private weak var textContainer: NSTextContainer?
116116

@@ -121,11 +121,11 @@ extension ASAttributedString {
121121
/// - url: 图片链接
122122
/// - placeholder: 占位图
123123
/// - Returns: 异步图片附件
124-
public static func image(_ url: URL?, placeholder: Image? = nil, _ style: Style = .original()) -> AsyncImageAttachment {
124+
public static func image(_ url: URL?, placeholder: ASImage? = nil, _ style: Style = .original()) -> AsyncImageAttachment {
125125
return .init(url, placeholder, style)
126126
}
127127

128-
init(_ url: URL?, _ placeholder: Image?, _ style: Style = .original()) {
128+
init(_ url: URL?, _ placeholder: ASImage?, _ style: Style = .original()) {
129129
self.url = url
130130
self.placeholder = placeholder
131131
self.loader = AsyncImageAttachment.Loader.init()
@@ -155,7 +155,7 @@ extension ASAttributedString {
155155
}
156156
}
157157

158-
public override func image(forBounds imageBounds: CGRect, textContainer: NSTextContainer?, characterIndex charIndex: Int) -> Image? {
158+
public override func image(forBounds imageBounds: CGRect, textContainer: NSTextContainer?, characterIndex charIndex: Int) -> ASImage? {
159159
self.textContainer = textContainer
160160
if image == placeholder {
161161
loadImage()
@@ -186,7 +186,7 @@ extension ASAttributedString {
186186
self.view = view
187187
self.style = style
188188
super.init(data: nil, ofType: nil)
189-
self.image = Image()
189+
self.image = ASImage()
190190
}
191191

192192
required init?(coder: NSCoder) {
@@ -335,7 +335,7 @@ fileprivate extension ASAttributedString.Attachment.Alignment {
335335
/// - lineHeight: 行高
336336
/// - Returns: 位置坐标
337337
func point(_ size: CGSize, with lineHeight: CGFloat) -> CGPoint {
338-
var font = Font.systemFont(ofSize: 18)
338+
var font = ASFont.systemFont(ofSize: 18)
339339
let fontSize = font.pointSize / (abs(font.descender) + abs(font.ascender)) * lineHeight
340340
font = .systemFont(ofSize: fontSize)
341341

@@ -421,7 +421,7 @@ public protocol AsyncImageAttachmentLoader: NSObject {
421421
/// - Parameters:
422422
/// - url: 链接
423423
/// - completion: 完成回调
424-
func loadImage(with url: URL, completion: @escaping (Swift.Result<Image, Swift.Error>) -> Void)
424+
func loadImage(with url: URL, completion: @escaping (Swift.Result<ASImage, Swift.Error>) -> Void)
425425
/// 取消加载
426426
func cancel()
427427
}
@@ -434,7 +434,7 @@ public class AsyncImageAttachmentURLSessionLoader: NSObject, AsyncImageAttachmen
434434
return downloadTask != nil
435435
}
436436

437-
public func loadImage(with url: URL, completion: @escaping (Result<Image, Error>) -> Void) {
437+
public func loadImage(with url: URL, completion: @escaping (Result<ASImage, Error>) -> Void) {
438438
downloadTask = URLSession.shared.dataTask(with: url) {
439439
[weak self] (data, response, error) in
440440
guard let self = self else { return }
@@ -446,7 +446,7 @@ public class AsyncImageAttachmentURLSessionLoader: NSObject, AsyncImageAttachmen
446446
}
447447
return
448448
}
449-
guard let image = Image(data: data) else {
449+
guard let image = ASImage(data: data) else {
450450
DispatchQueue.main.async {
451451
completion(.failure(NSError(domain: "Unable to create image", code: -2)))
452452
}

Sources/Attribute.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,15 @@ extension ASAttributedString.Attribute {
4444
return .init(attributes: value)
4545
}
4646

47-
public static func font(_ value: Font) -> Self {
47+
public static func font(_ value: ASFont) -> Self {
4848
return .init(attributes: [.font: value])
4949
}
5050

51-
public static func foreground(_ value: Color) -> Self {
51+
public static func foreground(_ value: ASColor) -> Self {
5252
return .init(attributes: [.foregroundColor: value])
5353
}
5454

55-
public static func background(_ value: Color) -> Self {
55+
public static func background(_ value: ASColor) -> Self {
5656
return .init(attributes: [.backgroundColor: value])
5757
}
5858

@@ -64,14 +64,14 @@ extension ASAttributedString.Attribute {
6464
return .init(attributes: [.kern: value])
6565
}
6666

67-
public static func strikethrough(_ style: NSUnderlineStyle, color: Color? = nil) -> Self {
67+
public static func strikethrough(_ style: NSUnderlineStyle, color: ASColor? = nil) -> Self {
6868
var temp: [NSAttributedString.Key: Any] = [:]
6969
temp[.strikethroughColor] = color
7070
temp[.strikethroughStyle] = style.rawValue
7171
return .init(attributes: temp)
7272
}
7373

74-
public static func underline(_ style: NSUnderlineStyle, color: Color? = nil) -> Self {
74+
public static func underline(_ style: NSUnderlineStyle, color: ASColor? = nil) -> Self {
7575
var temp: [NSAttributedString.Key: Any] = [:]
7676
temp[.underlineColor] = color
7777
temp[.underlineStyle] = style.rawValue
@@ -95,7 +95,7 @@ extension ASAttributedString.Attribute {
9595
return .init(attributes: [.shadow: value])
9696
}
9797

98-
public static func stroke(_ width: CGFloat = 0, color: Color? = nil) -> Self {
98+
public static func stroke(_ width: CGFloat = 0, color: ASColor? = nil) -> Self {
9999
var temp: [NSAttributedString.Key: Any] = [:]
100100
temp[.strokeColor] = color
101101
temp[.strokeWidth] = width

Sources/AttributedString.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@
1313

1414
#if os(macOS)
1515
import AppKit
16-
public typealias Image = NSImage
17-
public typealias Color = NSColor
18-
public typealias Font = NSFont
16+
public typealias ASImage = NSImage
17+
public typealias ASColor = NSColor
18+
public typealias ASFont = NSFont
1919
#else
2020
import UIKit
21-
public typealias Image = UIImage
22-
public typealias Color = UIColor
23-
public typealias Font = UIFont
21+
public typealias ASImage = UIImage
22+
public typealias ASColor = UIColor
23+
public typealias ASFont = UIFont
2424
#endif
2525

2626
public struct ASAttributedString {

Sources/Extension/ShadowExtension.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import WatchKit
2121

2222
public extension NSShadow {
2323

24-
convenience init(offset: CGSize, radius: CGFloat, color: Color? = .none) {
24+
convenience init(offset: CGSize, radius: CGFloat, color: ASColor? = .none) {
2525
self.init()
2626
self.shadowOffset = offset
2727
self.shadowBlurRadius = radius

0 commit comments

Comments
 (0)