Skip to content

Commit 1aa8728

Browse files
committed
修复点击事件崩溃
1 parent c7e668d commit 1aa8728

File tree

3 files changed

+7
-12
lines changed

3 files changed

+7
-12
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.3.4"
4+
s.version = "3.3.5"
55
s.summary = "基于Swift字符串插值快速构建你想要的富文本, 支持点击按住等事件获取, 支持多种类型过滤"
66

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

Sources/Extension/Extension.swift

+3-3
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ extension ASAttributedString {
138138
/// - lhs: AttributedString to add to.
139139
/// - rhs: AttributedString.Attribute to add.
140140
public static func += (lhs: inout ASAttributedString, rhs: ASAttributedString.Attribute) {
141-
lhs += (rhs, .init(location: 0, length: lhs.value.string.count))
141+
lhs += (rhs, .init(location: 0, length: lhs.value.length))
142142
}
143143

144144
/// Add a AttributedString.Attribute to another AttributedString.
@@ -147,7 +147,7 @@ extension ASAttributedString {
147147
/// - lhs: AttributedString to add to.
148148
/// - rhs: AttributedString.Attribute to add.
149149
public static func += (lhs: inout ASAttributedString, rhs: [ASAttributedString.Attribute]) {
150-
lhs += (rhs, .init(location: 0, length: lhs.value.string.count))
150+
lhs += (rhs, .init(location: 0, length: lhs.value.length))
151151
}
152152

153153
/// Add a AttributedString.Attribute to another AttributedString.
@@ -175,7 +175,7 @@ extension ASAttributedString {
175175
/// - rhs: AttributedString.Attribute to add.
176176
/// - Returns: New instance with added AttributedString.Attribute.
177177
public static func + (lhs: ASAttributedString, rhs: ASAttributedString.Attribute) -> ASAttributedString {
178-
return lhs + (rhs, .init(location: 0, length: lhs.value.string.count))
178+
return lhs + (rhs, .init(location: 0, length: lhs.value.length))
179179
}
180180

181181
/// Add a AttributedString.Attribute to another AttributedString and return a new AttributedString instance.

Sources/Extension/UIKit/UILabel/UILabelExtension.swift

+3-8
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,6 @@ extension UILabel {
416416
let scaledBaselineOffset: Double
417417
let scaledLineHeight: Double
418418
let scaledSize: CGSize
419-
let targetSize: CGSize
420419

421420
/// Keys
422421

@@ -427,7 +426,6 @@ extension UILabel {
427426
static let scaledBaselineOffsetName = "0V2cmZ2Tl5WasV2chJEZlxWYjN3X".reversedBase64Decoder()
428427
static let scaledLineHeightName = "=QHanlWZIVmbpxEZlxWYjN3X".reversedBase64Decoder()
429428
static let scaledSizeName = "=UmepNFZlxWYjN3X".reversedBase64Decoder()
430-
static let targetSizeName = "=UmepNFdldmchR3X".reversedBase64Decoder()
431429
}
432430

433431
private static let synthesizedAttributedTextName = "=QHelRFZlRXdilmc0RXQkVmepNXZoRnb5N3X".reversedBase64Decoder()
@@ -456,8 +454,7 @@ extension UILabel {
456454
let scaledAttributedTextName = ScaledMetrics.scaledAttributedTextName,
457455
let scaledBaselineOffsetName = ScaledMetrics.scaledBaselineOffsetName,
458456
let scaledLineHeightName = ScaledMetrics.scaledLineHeightName,
459-
let scaledSizeName = ScaledMetrics.scaledSizeName,
460-
let targetSizeName = ScaledMetrics.targetSizeName else {
457+
let scaledSizeName = ScaledMetrics.scaledSizeName else {
461458
return nil
462459
}
463460
guard
@@ -467,8 +464,7 @@ extension UILabel {
467464
let scaledAttributedText = object.value(forKey: scaledAttributedTextName) as? NSAttributedString,
468465
let scaledBaselineOffset = object.value(forKey: scaledBaselineOffsetName) as? Double,
469466
let scaledLineHeight = object.value(forKey: scaledLineHeightName) as? Double,
470-
let scaledSize = object.value(forKey: scaledSizeName) as? CGSize,
471-
let targetSize = object.value(forKey: targetSizeName) as? CGSize else {
467+
let scaledSize = object.value(forKey: scaledSizeName) as? CGSize else {
472468
return nil
473469
}
474470

@@ -479,8 +475,7 @@ extension UILabel {
479475
scaledAttributedText: scaledAttributedText,
480476
scaledBaselineOffset: scaledBaselineOffset,
481477
scaledLineHeight: scaledLineHeight,
482-
scaledSize: scaledSize,
483-
targetSize: targetSize
478+
scaledSize: scaledSize
484479
)
485480
}
486481

0 commit comments

Comments
 (0)