Skip to content

Commit

Permalink
修复点击事件崩溃
Browse files Browse the repository at this point in the history
  • Loading branch information
lixiang1994 committed Dec 12, 2022
1 parent c7e668d commit 1aa8728
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 12 deletions.
2 changes: 1 addition & 1 deletion AttributedString.podspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Pod::Spec.new do |s|

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

s.homepage = "https://github.com/lixiang1994/AttributedString"
Expand Down
6 changes: 3 additions & 3 deletions Sources/Extension/Extension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ extension ASAttributedString {
/// - lhs: AttributedString to add to.
/// - rhs: AttributedString.Attribute to add.
public static func += (lhs: inout ASAttributedString, rhs: ASAttributedString.Attribute) {
lhs += (rhs, .init(location: 0, length: lhs.value.string.count))
lhs += (rhs, .init(location: 0, length: lhs.value.length))
}

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

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

/// Add a AttributedString.Attribute to another AttributedString and return a new AttributedString instance.
Expand Down
11 changes: 3 additions & 8 deletions Sources/Extension/UIKit/UILabel/UILabelExtension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,6 @@ extension UILabel {
let scaledBaselineOffset: Double
let scaledLineHeight: Double
let scaledSize: CGSize
let targetSize: CGSize

/// Keys

Expand All @@ -427,7 +426,6 @@ extension UILabel {
static let scaledBaselineOffsetName = "0V2cmZ2Tl5WasV2chJEZlxWYjN3X".reversedBase64Decoder()
static let scaledLineHeightName = "=QHanlWZIVmbpxEZlxWYjN3X".reversedBase64Decoder()
static let scaledSizeName = "=UmepNFZlxWYjN3X".reversedBase64Decoder()
static let targetSizeName = "=UmepNFdldmchR3X".reversedBase64Decoder()
}

private static let synthesizedAttributedTextName = "=QHelRFZlRXdilmc0RXQkVmepNXZoRnb5N3X".reversedBase64Decoder()
Expand Down Expand Up @@ -456,8 +454,7 @@ extension UILabel {
let scaledAttributedTextName = ScaledMetrics.scaledAttributedTextName,
let scaledBaselineOffsetName = ScaledMetrics.scaledBaselineOffsetName,
let scaledLineHeightName = ScaledMetrics.scaledLineHeightName,
let scaledSizeName = ScaledMetrics.scaledSizeName,
let targetSizeName = ScaledMetrics.targetSizeName else {
let scaledSizeName = ScaledMetrics.scaledSizeName else {
return nil
}
guard
Expand All @@ -467,8 +464,7 @@ extension UILabel {
let scaledAttributedText = object.value(forKey: scaledAttributedTextName) as? NSAttributedString,
let scaledBaselineOffset = object.value(forKey: scaledBaselineOffsetName) as? Double,
let scaledLineHeight = object.value(forKey: scaledLineHeightName) as? Double,
let scaledSize = object.value(forKey: scaledSizeName) as? CGSize,
let targetSize = object.value(forKey: targetSizeName) as? CGSize else {
let scaledSize = object.value(forKey: scaledSizeName) as? CGSize else {
return nil
}

Expand All @@ -479,8 +475,7 @@ extension UILabel {
scaledAttributedText: scaledAttributedText,
scaledBaselineOffset: scaledBaselineOffset,
scaledLineHeight: scaledLineHeight,
scaledSize: scaledSize,
targetSize: targetSize
scaledSize: scaledSize
)
}

Expand Down

0 comments on commit 1aa8728

Please sign in to comment.