Commit b3785e7f authored by David黄金龙's avatar David黄金龙

行 间距

parent 1ce34384
...@@ -80,6 +80,21 @@ extension YHActivityDetailCell1 { ...@@ -80,6 +80,21 @@ extension YHActivityDetailCell1 {
func updateUI() { func updateUI() {
describeLable.text = dataModel.introduce describeLable.text = dataModel.introduce
// 创建NSMutableAttributedString实例
let attributedText = NSMutableAttributedString(string: dataModel.introduce)
// 设置行距,这里设置为10.0
let paragraphStyle = NSMutableParagraphStyle()
paragraphStyle.lineSpacing = 6.0 // 设置行距
// 将段落样式添加到NSMutableAttributedString
attributedText.addAttribute(.paragraphStyle, value: paragraphStyle, range: NSRange(location: 0, length: attributedText.length))
// 设置UILabel的attributedText属性
describeLable.attributedText = attributedText
describeLable.snp.updateConstraints { make in describeLable.snp.updateConstraints { make in
let topMargin = dataModel.introduce.isEmpty ? 0.0 : 24.0 let topMargin = dataModel.introduce.isEmpty ? 0.0 : 24.0
make.top.equalTo(nameLabel.snp.bottom).offset(topMargin) make.top.equalTo(nameLabel.snp.bottom).offset(topMargin)
......
...@@ -98,6 +98,19 @@ extension YHActivityTipsItemView { ...@@ -98,6 +98,19 @@ extension YHActivityTipsItemView {
return return
} }
describeLable.text = txt describeLable.text = txt
// 创建NSMutableAttributedString实例
let attributedText = NSMutableAttributedString(string: txt)
// 设置行距,这里设置为10.0
let paragraphStyle = NSMutableParagraphStyle()
paragraphStyle.lineSpacing = 6.0 // 设置行距
// 将段落样式添加到NSMutableAttributedString
attributedText.addAttribute(.paragraphStyle, value: paragraphStyle, range: NSRange(location: 0, length: attributedText.length))
// 设置UILabel的attributedText属性
describeLable.attributedText = attributedText
layoutIfNeeded() layoutIfNeeded()
} }
...@@ -105,7 +118,23 @@ extension YHActivityTipsItemView { ...@@ -105,7 +118,23 @@ extension YHActivityTipsItemView {
guard let model = dataModel else { guard let model = dataModel else {
return return
} }
describeLable.text = model.tips describeLable.text = model.tips
// 创建NSMutableAttributedString实例
let attributedText = NSMutableAttributedString(string: model.tips)
// 设置行距,这里设置为10.0
let paragraphStyle = NSMutableParagraphStyle()
paragraphStyle.lineSpacing = 6.0 // 设置行距
// 将段落样式添加到NSMutableAttributedString
attributedText.addAttribute(.paragraphStyle, value: paragraphStyle, range: NSRange(location: 0, length: attributedText.length))
// 设置UILabel的attributedText属性
describeLable.attributedText = attributedText
layoutIfNeeded() layoutIfNeeded()
} }
......
...@@ -34,6 +34,10 @@ class YHActivityTitleItemView: UIView { ...@@ -34,6 +34,10 @@ class YHActivityTitleItemView: UIView {
lable0.isEditable = false lable0.isEditable = false
lable0.isSelectable = false lable0.isSelectable = false
lable0.backgroundColor = .clear lable0.backgroundColor = .clear
lable0.textContainerInset = UIEdgeInsets.zero // 消除文本容器的内边距
lable0.textContainer.lineFragmentPadding = 0
return lable0 return lable0
}() }()
...@@ -99,11 +103,11 @@ extension YHActivityTitleItemView { ...@@ -99,11 +103,11 @@ extension YHActivityTitleItemView {
nameTextView.text = model.name nameTextView.text = model.name
if model.tag == 1 { if model.tag == 1 {
nameTextView.attributed.text = """ nameTextView.attributed.text = """
\(model.name + " ", .foreground(UIColor.mainTextColor), .font(UIFont.PFSC_B(ofSize:24)))\(.image(UIImage(named: "activity_vip_icon2")!,.custom(.offset(CGPoint(x: 0, y: -7)), size: .init(width: 44, height: 34)))) \(model.name + " ", .foreground(UIColor.mainTextColor), .font(UIFont.PFSC_B(ofSize:22)))\(.image(UIImage(named: "activity_vip_icon2")!,.custom(.offset(CGPoint(x: 0, y: -9.0)), size: .init(width: 44, height: 34))))
""" """
} else { } else {
nameTextView.attributed.text = """ nameTextView.attributed.text = """
\(model.name, .foreground(UIColor.mainTextColor), .font(UIFont.PFSC_B(ofSize:24))) \(model.name, .foreground(UIColor.mainTextColor), .font(UIFont.PFSC_B(ofSize:22)))
""" """
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment