Large layers in Core Animation
Large layers in Core Animation
- Subject: Large layers in Core Animation
- From: email@hidden
- Date: Wed, 18 Feb 2009 11:40:38 +0000
Hello
I'm writing an application that requires a large scrollable view
(about 500 x 8000) to display an appointments diary with lots of
entries. I had a satisfactory version working using traditional cocoa
objects but performance was a bit sluggish so I'd like to get it
working using Core Animation.
My plan was to have a single root layer (CATiledLayer) and small
sublayers (about 200 x 50) for each appointment. However, when I tried
it out, I found that whenever the size of the root layer exceeded 2000
or so in height (ie GPU limit), the sublayers became squashed rather
than tiled.
I'd gratefully appreciate any suggestions.
Thanks
Brian
TEST CODE:
BigLayerView.m
This class is set as the custom view of an NSScrollView in IB
- (void)awakeFromNib
{
CGFloat yHeight = 2000; // changing to 4000 results in squashed
sublayers...
CGRect layerRect = CGRectMake(0, 0, 1000, yHeight);
[self setFrame:NSRectFromCGRect(layerRect)];
CATiledLayer *myTiledLayer = [CATiledLayer layer];
myTiledLayer.frame = layerRect;
myTiledLayer.backgroundColor = CGColorGetConstantColor(kCGColorClear);
[self setLayer:myTiledLayer];
[self setWantsLayer:YES];
CGRect textRect = CGRectMake(10, 10, 100, 50);
for ( NSInteger i = 0; i <= 200; i++ ) {
CATextLayer *textLayer = [CATextLayer layer];
textLayer.fontSize = 36.0;
textLayer.frame = textRect;
textLayer.backgroundColor = CGColorGetConstantColor(kCGColorWhite);
textLayer.foregroundColor = CGColorGetConstantColor(kCGColorBlack);
textLayer.string = [NSString stringWithFormat:@"%i", i];
[myTiledLayer addSublayer:textLayer];
textRect.origin.y += 60;
}
}
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden