var normalImage: UIImage?
var selectImage: UIImage?
var scaleFactor: CGFloat = 1.3
override func playAnimation(_ icon: UIImageView, textLabel: UILabel) {
if let selectImage {
icon.image = selectImage
}
textLabel.textColor = textSelectedColor
icon.transform = CGAffineTransform(scaleX: scaleFactor, y: scaleFactor) // 保持放大
}
/// 取消选中恢复
override func deselectAnimation(_ icon: UIImageView, textLabel: UILabel, defaultTextColor: UIColor, defaultIconColor: UIColor) {
// 恢复默认 image
if let normalImage {
icon.image = normalImage
}
textLabel.textColor = defaultTextColor
icon.transform = .identity
}
/// 初始选中状态,保持放大
override func selectedState(_ icon: UIImageView, textLabel: UILabel) {
if let selectImage {
icon.image = selectImage
}
textLabel.textColor = textSelectedColor
icon.transform = CGAffineTransform(scaleX: scaleFactor, y: scaleFactor)
}
class RAMScaleAnimation: RAMItemAnimation {
}