97 lines
2.8 KiB
Swift
97 lines
2.8 KiB
Swift
//
|
|
// QuickMessageView.swift
|
|
// QuickLocation
|
|
//
|
|
// Created by 八条 on 2026/6/15.
|
|
//
|
|
|
|
import UIKit
|
|
import TagListView
|
|
|
|
class QuickMessageView: UIView {
|
|
|
|
private let list: [String] = [
|
|
"爱你哦!", "预计到达时间?", "发生什么情况?", "注意安全", "在路上", "给我打电话",
|
|
]
|
|
|
|
func setupTagData(list: [String]) {
|
|
tagListView.removeAllTags()
|
|
for text in list {
|
|
let tag = TTGTextTag.init()
|
|
|
|
let content = TTGTextTagStringContent.init(text: text)
|
|
content.textColor = ThemeManager.shared.color.titleAuxColor
|
|
content.textFont = UIFont.systemFont(ofSize: 12, weight: .medium)
|
|
|
|
let normalStyle = TTGTextTagStyle.init()
|
|
normalStyle.backgroundColor = .white
|
|
normalStyle.extraSpace = CGSize.init(width: 15, height: 15)
|
|
normalStyle.shadowColor = UIColor(hexStr: "#333333", alpha: 0.25)
|
|
normalStyle.borderColor = .clear
|
|
normalStyle.cornerRadius = 8
|
|
|
|
tag.content = content
|
|
tag.style = normalStyle
|
|
|
|
tagListView.addTag(tag)
|
|
}
|
|
tagListView.reload()
|
|
tagListView.setNeedsLayout()
|
|
tagListView.layoutIfNeeded()
|
|
}
|
|
|
|
private func setupRx() {
|
|
|
|
}
|
|
|
|
private func setupUI() {
|
|
addSubview(closeBtn)
|
|
addSubview(tagListView)
|
|
|
|
closeBtn.layoutChain
|
|
.top()
|
|
.left(23)
|
|
.width(40)
|
|
.height(40)
|
|
|
|
tagListView.layoutChain
|
|
.topToBottomOfView(closeBtn, offset: 15)
|
|
.edgesHorzontal(15)
|
|
.height(38)
|
|
}
|
|
|
|
lazy var closeBtn: UIButton = {
|
|
let btn = UIButton(type: .custom)
|
|
btn.setImage(UIImage(named: "Common/x"), for: .normal)
|
|
btn.setBackgroundColor(.black.withAlphaComponent(0.5), for: .normal)
|
|
btn.cornerRadius = 20
|
|
btn.extendEdgeInsets = UIEdgeInsets(top: 50, left: 23, bottom: 0, right: 30)
|
|
return btn
|
|
}()
|
|
|
|
lazy var tagListView: TTGTextTagCollectionView = {
|
|
let tagsView = TTGTextTagCollectionView.init(frame: .zero)
|
|
tagsView.scrollView.scrollsToTop = false
|
|
tagsView.scrollView.bounces = false
|
|
tagsView.showsVerticalScrollIndicator = false
|
|
tagsView.showsHorizontalScrollIndicator = false
|
|
tagsView.scrollDirection = .horizontal
|
|
tagsView.numberOfLines = 1
|
|
tagsView.horizontalSpacing = 10
|
|
return tagsView
|
|
}()
|
|
|
|
override init(frame: CGRect) {
|
|
super.init(frame: frame)
|
|
backgroundColor = .clear
|
|
setupUI()
|
|
setupRx()
|
|
setupTagData(list: list)
|
|
}
|
|
|
|
required init?(coder aDecoder: NSCoder) {
|
|
fatalError("init(coder:) has not been implemented")
|
|
}
|
|
|
|
}
|