Does clipsToBounds = YES reduce memory?

I have a pretty big view like 1000 x 1000. So I did clipToBounds = YES. Will it create smaller bitmaps for views?

+3
source share
3 answers

I think probably not - you still need to allocate memory for the presentation, just don’t display it.

You will probably get a very small increase in performance, since UIKit knows more about what / what not to draw.

! , 1000 1000x1000 . . clipToBounds, YES, , !

, , - , , !

,


mystify , :

1) XCode - Window

2) :

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {    

    // Override point for customization after application launch
    [window setClipsToBounds:YES];
    [window makeKeyAndVisible];

    // Make some views
    for (int n = 0; n < 100000; ++n) {
        UIImageView *view = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"image.jpg"]];
        [view setFrame:CGRectMake(0, 0, 1000, 1000)];
        [window addSubview:view];
        [view release];
    }

    return YES;
}

3)

4) - .

, - 16 clipsToBounds, YES NO .

-

a) UIImageView, , , - - UIView.

b) ( iPhone , ) - 99% , - , , isn 't 100% , , , .

+1

clipsToBounds . clipToBounds, , (, ), . .

"", , , , , . .

+3

. clipsToBounds subviews, . UIView CATiledLayer . CATiledLayer , , (, Google ).

EDIT: By the way, UIKit is smart enough not to display things that are not visible, either due to the screen or obscured by other views. However, since you already hold the entire view in memory, this is unlikely to help in memory usage, but only at rendering speed.

+1
source

Source: https://habr.com/ru/post/1738815/


All Articles