I refactored the isHighlighted code this instead. Even shorter.
override var isHighlighted: Bool {
didSet {
UIView.animate(withDuration: 0.5, delay: 0, usingSpringWithDamping: 1, initialSpringVelocity: 1, options: .curveEaseOut, animations: {
self.transform = self.isHighlighted ? .init(scaleX: 0.9, y: 0.9) : .identity
})
}
}