iphone - Performance of drawRect -
hey guys quick question performance of drawrect: i've noticed lot of topics people complaining performance issues.
in app, need draw ~150 squares overtop underlaying views. many calls isn't going have noticeable user difference, i'm wondering pros , cons going forward. i'm debating 2 ways:
1) add transparent uiview subclass on top custom drawrect: facilitate drawing
2) add normal square subviews
as said, using cadisplaylink there won't difference user, i'm curious more efficient? (2) kind of ridiculous way of doing it, adding instances useless functionality appearance, these posts have scared me using drawrect. drawrect inefficient?
thanks
perhaps unintuitively, drawrect: isn't called every frame. in fact, if nothing special in view , view doesn't changed, gets called once.
you can force called calling [myview setneedsdisplay], there no reason to.
if have view overlapping subviews, still each of views, including superview, drawrect: called once. then, gpu compositing (blending).
a custom drawrect: slower (and harder) using uikit way intended, if uikit offers want do.
also don't fall 1 of biggest traps in software development, premature optimization. code naive version, benchmark it, , if it's fast enough, it's enough, , can focus energy elsewhere. start optimizing once know that slow, , where , why is.
Comments
Post a Comment