Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial

James Yu
2,227 PointsHow to Adjust Swift Animation Speed?
Hi all,
I'm new to programming, so please excuse any lack of clarity. I'm trying to make one of my buttons have a "blinking effect" using the animateWithDuration method. Currently, it works as a "fade," where the button gradually shows up and disappears every 1 second (I set the duration to be 1.0). I'm hoping to reduce the speed of the animation (not the duration, but the speed), so that the animation effect would occur more abruptly. The interval of the animation needs to stay at every 1 second. Is this possible to accomplish? I've been researching, and it seems like animateWithDuration doesn't allow this sort of specification... Do I need to approach this via another method? I'm including my code below. Thanks for your help! Btw, this is all under UIViewController in UIKit.
override func viewDidLoad() {
super.viewDidLoad()
self.tapButton.alpha = 0
}
override func viewDidAppear(animated: Bool) {
super.viewDidAppear(true)
UIView.animateWithDuration(1.0, delay: 0, options: .Repeat | .AllowUserInteraction | .Autoreverse, animations: { () -> Void in self.tapButton.alpha = 1.0
}, completion: nil )
}
1 Answer

Caleb Kleveter
Treehouse Moderator 37,862 PointsAre you using images? If so you just create 2 images, one faded, the other one not.