Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
lixiang1994 committed Aug 12, 2020
1 parent 23608f7 commit 81796c2
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 4 deletions.
4 changes: 2 additions & 2 deletions Demo/Demo/Debug/Debug.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -251,8 +251,8 @@
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="PingFang" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="cft-PD-lmZ">
<rect key="frame" x="96.333333333333329" y="6" width="63.666666666666671" height="18"/>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text=".SFUI-Regular" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="cft-PD-lmZ">
<rect key="frame" x="96.333333333333314" y="6" width="95.666666666666686" height="18"/>
<fontDescription key="fontDescription" type="system" pointSize="15"/>
<color key="textColor" systemColor="placeholderTextColor" red="0.23529411759999999" green="0.23529411759999999" blue="0.26274509800000001" alpha="0.29999999999999999" colorSpace="custom" customColorSpace="sRGB"/>
<nil key="highlightedColor"/>
Expand Down
1 change: 1 addition & 0 deletions Demo/Demo/Debug/DebugLabelView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ extension DebugLabelView {
func set(text: AttributedString) {
// 富文本中如果包含段落样式 则无法进行多行字号缩放
label.attributed.text = text
// 刷新布局
layoutIfNeeded()
}

Expand Down
2 changes: 1 addition & 1 deletion Demo/Demo/Debug/DebugLabelViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class DebugLabelViewController: ViewController<DebugLabelView> {
private var attributes: [AttributedString.Attribute] = []
private var paragraphs: [AttributedString.Attribute.ParagraphStyle] = []
private var attributedString: AttributedString = """
我的名字叫李响,我的手机号码是18611401994,我的电子邮件地址是[email protected],现在是2020/06/28 20:30。我的GitHub主页是https://github.com/lixiang1994。欢迎来Star! \("点击联系我", .action({ }))
我的名字叫李响,我的手机号码是18611401994,我的电子邮件地址是[email protected],现在是2020/06/28 20:30。我的GitHub主页是https://github.com/lixiang1994。欢迎来Star! \("点击联系我", .action({ }))
"""

override func viewDidLoad() {
Expand Down
2 changes: 1 addition & 1 deletion Sources/Extension/UIKit/UILabel/UILabelExtension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ extension UILabel {
) { (value, range, stop) in
guard let old = value as? NSParagraphStyle else { return }
guard let new = old.mutableCopy() as? NSMutableParagraphStyle else { return }
new.lineBreakMode = numberOfLines == 1 ? .byCharWrapping : .byWordWrapping
new.lineBreakMode = .byWordWrapping
if #available(iOS 11.0, *) {
new.setValue(1, forKey: "lineBreakStrategy")
}
Expand Down

0 comments on commit 81796c2

Please sign in to comment.