Kevin
Kevin

Reputation: 1157

About redrawing of "addSubview" function

if I code these:

UIView *topView = [UIView new];

for (int i = 0; i < 100; i++) {

    UIView *childView = [UIView new];
    [topView addSubview:childView]
}

Does topView redraw every time when I called the "addSubview" function?

Upvotes: 1

Views: 331

Answers (1)

rob mayoff
rob mayoff

Reputation: 386038

No, topView does not redraw every time. It is simply flagged as "needs display" each time, which is a cheap operation. When you return to the run loop, the run loop will tell topView to actually redraw itself and clear the "needs display" flag.

Upvotes: 1

Related Questions