ios - execute drawRect on every frame? -
i'm trying implement custom view visualizes value changing in real time (like example volume of audio output), , achieve have drawrect execute every animation frame render correct view state value.
the solution can think of set timer execute 60 times per second, , call view.setneedsdisplay()
i'm sure not best way behavior , guarantee smooth performance.
edit give slightly more concrete example
so situation have this:
//there variable changing continuously var dynamicfoo : double! //i want create view class renders foo in real-time class foovisualizerview : uiview { //i have drawing code renders foo @ given value override func drawrect(rect: cgrect) { valuedependantdrawfunction(dynamicfoo) } }
ideally foovisualizerview
redraw on every animation frame.
a cadisplaylink
sounds want - timer called every time screen updated. can call setneedsdisplay
display link method.
note though code needs complete in 1/60 of second method or terrible.
Comments
Post a Comment