我曾使用UIStackView進行單元格設計。現在我必須在文本 "Inprocess "旁邊添加一個黃點視圖。我們怎樣才能做到呢?
let backView = UIView(color: AppColor.appWhite, cornerRadius: 18)
lazy var advanceStack = VerticalStackView(arrangedSubViews: [SalaryadvanceLabel, $99advanceValue], spacing: 3, distribution: .fillEqually)
lazy var StatusStack = VerticalStackView( arrangedSubViews: [Inprocesslabel, timelabel], spacing: 3, distribution: .fillEqually)
lazy var infoStack = HorizontalStackView(arrangedSubViews: [ advanceStack, StatusStack], spacing: 10, distribution: .fillEqually)
let指標。UIView = {
let view = UIView(color: AppColor.appGreen, cornerRadius: 3)
view.constraintWidth(constant: 6)
view.constraintHeight(常數: 6)
return view
}()
override init(style: UITableViewCell.CellStyle, reuseIdentifier。String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
backgroundColor = AppColor.appBackground
selectionStyle = .none
setupView()
indicator.isHidden = true
}
private func setupView(){
addSubview(backView)
backView.anchor(top: topAnchor, leading: leadingAnchor, bottom: bottomAnchor, trailing: trailingAnchor, padding: .init(top: 8, left: 12, bottom: 0, right: 12)
backView.addSubview(infoStack)
infoStack.anchor(top: nil, leading: backView.leadingAnchor, bottom: nil, trailing: backView.trailingAnchor, padding: .init(top: 0, left: 20, bottom: 0, right: 20)
infoStack.centerYInSuperview()
backView.addSubview( indicator)
indicator.anchor(top: infoStack.bottomAnchor, leading: nil, bottom: nil, trailing: chargeValue.trailingAnchor, padding: .init(top: 6, left: 0, bottom: 0, right: 0)
uj5u.com熱心網友回復:
這就是你如何用一個帶有類似于點的字符的attributedText來做這件事(在評論中已經建議)
let attributedText = NSMutableAttributedString(string: "- In process")
let屬性。[NSAttributedString.Key : Any] = [
.foregroundColor: UIColor.systemYellow
]
attributedText.addAttributes(attribute, range: NSRange(location: 0, length: 1)
inProcessLabel. attributedText = attributedText
uj5u.com熱心網友回復:
我使用了下面的代碼并將其添加到UIStackView中。問題解決了。
let StatusDot = UILabel(text: "u{2022}" , color: AppColor.appBlack, font: Helvetica.bold, size: 40, alignment: .right)
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/333990.html
標籤:
上一篇:當我們從FireStore獲取資料時,tableview.reloaddata()在Dispatchqueue.main.sync之外仍然有效。
下一篇:我怎樣才能提高插入速度?

