mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
38 lines
1.1 KiB
Swift
38 lines
1.1 KiB
Swift
//
|
|
// UILabel+Utils.swift
|
|
// GraphTest
|
|
//
|
|
// Created by Andrei Salavei on 4/9/19.
|
|
// Copyright © 2019 Andrei Salavei. All rights reserved.
|
|
//
|
|
|
|
import UIKit
|
|
|
|
extension UILabel {
|
|
func setTextColor(_ color: UIColor, animated: Bool) {
|
|
if self.textColor != color {
|
|
if animated {
|
|
let animation = CATransition()
|
|
animation.timingFunction = CAMediaTimingFunction.init(name: .linear)
|
|
animation.type = .fade
|
|
animation.duration = .defaultDuration
|
|
self.layer.add(animation, forKey: "kCATransitionColorFade")
|
|
}
|
|
self.textColor = color
|
|
}
|
|
}
|
|
|
|
func setText(_ title: String?, animated: Bool) {
|
|
if self.text != title {
|
|
if animated {
|
|
let animation = CATransition()
|
|
animation.timingFunction = CAMediaTimingFunction.init(name: .linear)
|
|
animation.type = .fade
|
|
animation.duration = .defaultDuration
|
|
self.layer.add(animation, forKey: "kCATransitionTextFade")
|
|
}
|
|
self.text = title
|
|
}
|
|
}
|
|
}
|