/// 增加動態(tài)下劃線
func addDynamicLine(baseView: UIView, lineAdd: UIView,lineColor: UIColor) {
baseView.addSubview(lineAdd)
lineAdd.backgroundColor = lineColor
lineAdd.snp.makeConstraints { (make) in
make.leading.equalTo(baseView).offset(0)
make.trailing.equalTo(baseView).offset(0)
make.bottom.equalTo(baseView).offset(0)
make.height.equalTo(1)
}
let lineTran = CGAffineTransform(translationX: 0, y: 0)
lineAdd.transform = lineTran.scaledBy(x: 0, y: 1)
}
/// 下劃線動態(tài)顯示折欠,文字動態(tài)縮放
func showDynamicLineAndScaleLabel(line: UIView,label: UILabel,widthLabel: CGFloat) {
UIView.animate(withDuration: 0.2) {
let trans = CGAffineTransform(translationX: -(8+widthLabel/4), y: -24)
label.transform = trans.scaledBy(x: 0.5, y: 0.5)
label.textColor = UIColor(hex: 0xFDAE1B)
let lineTran = CGAffineTransform(translationX: 0, y: 0)
line.transform = lineTran.scaledBy(x: 1, y: 1)
}
}
/// 下劃線隱藏召衔,文字動態(tài)擴(kuò)大
func hiddenDynamicLineAndScaleLabel(line: UIView,label: UILabel) {
UIView.animate(withDuration: 0.2) {
label.transform = CGAffineTransform.identity
label.textColor = UIColor(hex: 0x808795)
let lineTran = CGAffineTransform(translationX: 0, y: 0)
/// 調(diào)為零消失很快,看不到消失效果
line.transform = lineTran.scaledBy(x: 0.00000001, y: 1)
}
}