I want to create a circular view so that the color of the border line is repeated endlessly from red to blue and from blue to red.
The following method changes from red to blue, but it stops and does not repeat itself.
I have included [UIViewAnimationOptions.Autoreverse, UIViewAnimationOptions.Repeat] in the options, so I thought there was no problem.
Is there anything missing?
// Make it circular at this point
button.layer.cornerRadius=button.frame.size.width/2;
button.layer.masksToBounds = true;
// borderline
button.layer.borderWidth=5.0;
// border color
button.layer.borderColor=UIColor.redColor().CGColor
UIView.animateWithDuration(1, delay:1, options:[UIViewAnimationOptions.Autoreverse, UIViewAnimationOptions.Repeat], animations:{()->Void in
self.button.layer.borderColor=UIColor.blueColor().CGColor
}, completion: {_in
self.button.layer.borderColor=UIColor.redColor().CGColor
})
I tried copying and modifying the code, but the color of self.button.layer.borderColor did not change in animation.
When I added an animation to move the view and an animation to change the background, it seems that it can be played repeatedly.
I will list the modified code for your reference.
// Make it circular at this point
self.button.layer.cornerRadius=button.frame.size.width/2;
self.button.layer.masksToBounds=true;
// borderline
self.button.layer.borderWidth=5.0;
// border color
self.button.layer.borderColor=UIColor.greenColor().CGColor
// Specify initial location
button.layer.position = CGPoint (x:self.view.frame.width/2, y:200)
// Specify background color
self.button.backgroundColor=UIColor.orangeColor()
UIView.animateWithDuration(1, delay:1, options:[UIViewAnimationOptions.Autoreverse, UIViewAnimationOptions.Repeat], animations:{()->Void in
self.button.layer.borderColor=UIColor.blueColor().CGColor
// Move Animation
self.button.layer.position = CGPoint (x:self.view.frame.width/2, y:500)
// Background animation
self.button.backgroundColor=UIColor.greenColor()
}, completion: {_in
// self.button.layer.borderColor=UIColor.redColor().CGColor
})
According to the URL below, the borderColor of CaLayer cannot be animated in UI/animation.
http://qiita.com/ShingoFukuyama/items/66d2ca049e15bd340538
What do you think about the border being blue from the beginning without animation?
There seems to be a separate solution to the above URL, so why don't you refer to it?
XCode version is 7.3.1 (7D1014), iPad 4th, iOS 9.3.2 (13F69) verified.
574 Who developed the "avformat-59.dll" that comes with FFmpeg?
912 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
578 Understanding How to Configure Google API Key
572 rails db:create error: Could not find mysql2-0.5.4 in any of the sources
610 GDB gets version error when attempting to debug with the Presense SDK (IDE)
© 2024 OneMinuteCode. All rights reserved.