Skip to content

Commit dacc8fb

Browse files
committed
补充ASAttributedString.Attribute
1 parent bff77aa commit dacc8fb

File tree

3 files changed

+72
-7
lines changed

3 files changed

+72
-7
lines changed

AttributedString.podspec

+1-1
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.2.0"
4+
s.version = "3.3.0"
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

+19-6
Original file line numberDiff line numberDiff line change
@@ -54,33 +54,46 @@
5454
debugDocumentVersioning = "YES"
5555
debugServiceExtension = "internal"
5656
allowLocationSimulation = "YES">
57-
<BuildableProductRunnable
58-
runnableDebuggingMode = "0">
57+
<RemoteRunnable
58+
runnableDebuggingMode = "2"
59+
BundleIdentifier = "com.apple.Carousel"
60+
RemotePath = "/Demo-Watch WatchKit App">
5961
<BuildableReference
6062
BuildableIdentifier = "primary"
6163
BlueprintIdentifier = "9B267B4D24405CFA002F571E"
6264
BuildableName = "Demo-Watch WatchKit App.app"
6365
BlueprintName = "Demo-Watch WatchKit App"
6466
ReferencedContainer = "container:Demo-Watch.xcodeproj">
6567
</BuildableReference>
66-
</BuildableProductRunnable>
68+
</RemoteRunnable>
6769
</LaunchAction>
6870
<ProfileAction
6971
buildConfiguration = "Release"
7072
shouldUseLaunchSchemeArgsEnv = "YES"
7173
savedToolIdentifier = ""
7274
useCustomWorkingDirectory = "NO"
7375
debugDocumentVersioning = "YES">
74-
<BuildableProductRunnable
75-
runnableDebuggingMode = "0">
76+
<RemoteRunnable
77+
runnableDebuggingMode = "2"
78+
BundleIdentifier = "com.apple.Carousel"
79+
RemotePath = "/Demo-Watch WatchKit App">
7680
<BuildableReference
7781
BuildableIdentifier = "primary"
7882
BlueprintIdentifier = "9B267B4D24405CFA002F571E"
7983
BuildableName = "Demo-Watch WatchKit App.app"
8084
BlueprintName = "Demo-Watch WatchKit App"
8185
ReferencedContainer = "container:Demo-Watch.xcodeproj">
8286
</BuildableReference>
83-
</BuildableProductRunnable>
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>
8497
</ProfileAction>
8598
<AnalyzeAction
8699
buildConfiguration = "Debug">

Sources/Attribute.swift

+52
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ extension ASAttributedString {
4040

4141
extension ASAttributedString.Attribute {
4242

43+
public static func custom(_ value: [NSAttributedString.Key: Any]) -> Self {
44+
return .init(attributes: value)
45+
}
46+
4347
public static func font(_ value: Font) -> Self {
4448
return .init(attributes: [.font: value])
4549
}
@@ -125,6 +129,54 @@ extension ASAttributedString.Attribute {
125129
}
126130
}
127131

132+
#if os(macOS)
133+
134+
extension ASAttributedString.Attribute {
135+
136+
public static func cursor(_ value: NSCursor) -> Self {
137+
return .init(attributes: [.cursor: value])
138+
}
139+
140+
public static func markedClauseSegment(_ value: Int) -> Self {
141+
return .init(attributes: [.markedClauseSegment: value])
142+
}
143+
144+
public static func spellingState(_ value: SpellingState) -> Self {
145+
return .init(attributes: [.spellingState: value.rawValue])
146+
}
147+
148+
public static func superscript(_ value: Int) -> Self {
149+
return .init(attributes: [.superscript: value])
150+
}
151+
152+
public static func textAlternatives(_ value: NSTextAlternatives) -> Self {
153+
return .init(attributes: [.textAlternatives: value])
154+
}
155+
156+
public static func toolTip(_ value: String) -> Self {
157+
return .init(attributes: [.toolTip: value])
158+
}
159+
}
160+
161+
extension ASAttributedString.Attribute {
162+
163+
/**
164+
This enum controls the display of the spelling and grammar indicators on text,
165+
highlighting portions of the text that are flagged for spelling or grammar issues.
166+
This should be used with `Attribute.spellingState`.
167+
*/
168+
public enum SpellingState: Int {
169+
170+
/// The spelling error indicator.
171+
case spelling = 1
172+
173+
/// The grammar error indicator.
174+
case grammar = 2
175+
}
176+
}
177+
178+
#endif
179+
128180
extension ASAttributedString.Attribute {
129181

130182
public enum WritingDirection {

0 commit comments

Comments
 (0)