Reputation: 149
The following code runs once and it doesn't even animate..it just appears 20 pixels higher. Any idea why? What I want is for the button to move up and down forever.
scrollButton.frame = CGRectMake(CGRectGetMidX(self.view.frame)-20, (self.view.frame.size.height-64)*1-80, 40, 16)
scrollButton.setImage(UIImage(named: "ARROW.png"), forState: .Normal)
scrollButton.tintColor = UIColor.whiteColor()
self.scrollView.addSubview(scrollButton)
UIView.animateWithDuration(1.0, delay: 0, options: UIViewAnimationOptions.Repeat | UIViewAnimationOptions.Autoreverse, animations: {
self.scrollButton.frame.origin.y -= 20
}, completion: nil)
Upvotes: 4
Views: 923
Reputation: 1367
Although this question is quite old I wanted to add some light to new users.
UIView Animations doesn't work well when called from viewDidLoad try calling it instead from viewWillAppear.
Hope it helps.
Upvotes: 1
Reputation: 125
I am not sure if that is going to work well , you can make two functions and each one has to move the body and then call the other one . You can use a boolean variable to stop the functions work.
Upvotes: 0