动态下划线和字体动态缩放

/// 增加动态下划线
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)

}

/// 下划线动态显示,文字动态缩放
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)
    
}

}

/// 下划线隐藏,文字动态扩大
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)
    /// 调为零消失很快,看不到消失效果
    line.transform = lineTran.scaledBy(x: 0.00000001, y: 1)
}

}

©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容