ios - drawRect appropriate for animation code? -
i set animation code in drawrect in uiview subclass. looking uiviewcontroller's viewwillappear. wanted utilize uiview rather uiviewcontroller. using code below. appropriate set animation code in drawrect? animation startup animation when view shown.
- (void)drawrect:(cgrect)rect { [_graphview setframe:cgrectmake(0.0f, 0.0f, 30.0 + (_defaultarray.count * step_x), self.frame.size.height)]; [self setcontentsize:cgsizemake(30.0 + (_defaultarray.count * step_x), _graphview.frame.size.height)]; float delayinseconds = 0.25f; dispatch_time_t poptime = dispatch_time(dispatch_time_now, delayinseconds * nsec_per_sec); dispatch_after(poptime, dispatch_get_main_queue(), ^(void){ if (_graphview.frame.size.width > graph_width) [self setcontentoffset:cgpointmake(_graphview.frame.size.width - graph_width, 0.0f) animated:yes]; }); }
no, terrible idea. thing should in implementation of -drawrect: draw contents of view. none of code doing close that.
(if view subclass of uiscrollview, shouldn't overriding -drawrect: @ all.)
that code looks more appropriate in view controller, or perhaps in view's setup code (does create _graphview itself?). without knowing more rest of code, it's hard suggest belongs.
ios uiview
No comments:
Post a Comment