I recently learned how to animate a button using alpha so that it fades out in Swift. However, if I would like to change only the alpha of the border itself, the animation does not seem to work. Instead, it βjumpsβ from state to state.
UIView.animateWithDuration(1.0, delay: 0.0, options: nil, animations: { var borderColor = UIColor(red: 0.41, green: 1.28, blue: 1.85, alpha: 0.0) self.startButton.layer.borderColor = borderColor.CGColor }, completion: nil);
The above code, for example, is not animated; instead, it creates a βjumpβ between alpha 1.0 and 0.0 borders.
However, this will work fine (changing the alpha of the whole button):
UIView.animateWithDuration(1.0, delay: 0.0, options: nil, animations: { self.startButton.alpha = 1; }, completion: nil);
Is there any way around this problem?
source share