ios - 如何快速将点视图添加到文本中?
问题描述
我曾使用 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 indicator: UIView = {
let view = UIView(color: AppColor.appGreen, cornerRadius: 3)
view.constraintWidth(constant: 6)
view.constraintHeight(constant: 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))
}
解决方案
我使用以下代码并将其添加到 UIStackView。问题解决了。
let StatusDot = UILabel(text: "\u{2022}" , color: AppColor.appBlack, font: Helvetica.bold, size: 40, alignment: .right)
推荐阅读
- python - 将文本文件中的值存储到变量中并返回
- android - 应用动画后,图层列表在第二个活动中失去其形状
- c - 读取整数,直到用户达到负整数或整数数达到 15
- macos - 在 mac OS 10.13 中安装 Mcrypt 扩展的问题
- wordpress - 编辑 woocommerce 结帐页面“订单备注”
- codeigniter - 如何在codeigniter中获取选择最大值
- html - 基于路由的 Angular 子导航
- jquery - 对话框标签在 Mozilla Firefox 中不起作用?
- jmeter - n 绘制如何在自定义线程 Arrivals Thread Group 和 Free-Form Arrivals Thread Group 中计算总到达率的图表;
- javascript - 下拉列表的更改事件无法触发