swift - iOS Todays Widget Extension - Animate UISlider -


i'm creating todays extension within ios. i'm trying animate value change on uislider added in todays extension. animation should proceed start value end value.

i tried in 2 ways: first uiview animation

func updatesliderview(beginstate:float, duration: nstimeinterval) {     sliderview.hidden = false     sliderview.setvalue(beginstate, animated: false)     uiview.animatewithduration(duration) { () -> void in         self.sliderview.setvalue(1, animated: true)     } } 

second basic animation.

func updatesliderview(beginstate:float, duration: nstimeinterval) {     sliderview.hidden = false     guard let _ = sliderview.layer.animationforkey("slider.animation.value") else {         let animation = cabasicanimation(keypath: "value")         animation.fromvalue = beginstate         animation.tovalue = 1         animation.removedoncompletion = true         sliderview.layer.addanimation(animation, forkey: "slider.animation.value")         return     } } 

i'm doing new xcode 7.0.1 ios target 8.1 in both result ends without animation. uislider have user interaction disabled. i'm using uisluder because have custom graphics slider path min & max track , slider thumb.

i did third test

sliderview.setvalue(beginstate, animated: false) catransaction.begin() catransaction.setanimationduration(duration) sliderview.setvalue(1, animated: true) catransaction.commit() 

it wont work :/

summary: uiview.animation works. it's animating it's breaking customs graphic uislider , it's not setting start value slider.

how can animate uislider value change in todays extension??

ok solved out. answer own question because maybe , it's solution asking for.

only uiview.animation animating uislider inside todays extension. setting starting value not working before animation , animation breaking custom graphics on slider. figured out when set starting value in uiview.animation block everthing work wanted.

uiview.animatewithduration(0.2, delay: 0, options: .curvelinear, animations: { () -> void in         self.sliderview.setvalue(beginstate, animated: true)         }) { (completed) -> void in             uiview.animatewithduration(duration, delay: 0.1, options: .curvelinear, animations: { () -> void in                 self.sliderview.setvalue(1, animated: true)                 }, completion: nil)     } 

i combined 2 blocks of uiview animation. result expected before. starting value set. uislider value animated starting value end. custom graphics min, max , thumb rendered correctly.


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -