Im currently working on an universal app, and in one of my view controllers i have the following xib:
View
-ImageView
-TableView
-ImageView
-View (called tblviewContainer in the following snippet of code)
In my viewdidload method i have made an layer which i will put on my view(tblviewcontainer) so that some of the top and the bottom of the screen is gradient.
[tblViewContainer addSubview:self.tableView];
[tblViewContainer sendSubviewToBack:self.tableView];
if (!maskLayer)
{
maskLayer = [CAGradientLayer layer];
UIColor* outerColorSetup = [UIColor colorWithWhite:1.0 alpha:0.0];
UIColor* innerColorSetup = [UIColor colorWithWhite:1.0 alpha:1.0];
CGColorRef outerColor = outerColorSetup.CGColor;
CGColorRef innerColor = innerColorSetup.CGColor;
maskLayer.colors = [NSArray arrayWithObjects:
(__bridge id )outerColor,
(__bridge id)innerColor,
(__bridge id)innerColor,
(__bridge id)outerColor, nil];
maskLayer.locations = [NSArray arrayWithObjects:
[NSNumber numberWithFloat:0.01],
[NSNumber numberWithFloat:0.04],
[NSNumber numberWithFloat:0.8],
[NSNumber numberWithFloat:1.0], nil];
maskLayer.bounds = CGRectMake(0, 0,
self.tableView.frame.size.width,
self.tableView.frame.size.height);
maskLayer.anchorPoint = CGPointZero;
tblViewContainer.layer.mask = maskLayer;
}
In my app it is possible to rotate, and when i do that with the layer on, it is very slow/laggy when i rotate (only on ipad 3!).
When i rotate i do the following: (from portrait->landscape)
-(void)willRotateToInterfaceOrientation: (UIInterfaceOrientation)orientation duration:(NSTimeInterval)duration
{
if (orientation == UIInterfaceOrientationPortrait || orientation == UIInterfaceOrientationPortraitUpsideDown)
{
}
else if(orientation == UIInterfaceOrientationLandscapeLeft || orientation == UIInterfaceOrientationLandscapeRight)
{
_landscape = [[ipad_VideoListViewController_Landscape alloc] initWithNibName:@"ipad_VideoListViewController_Landscape" bundle:nil];
_landscape.scroolViewContentOffset = scroolViewContentOffset;
[self.view.layer setRasterizationScale:[UIScreen mainScreen].scale];
self.view.layer.shouldRasterize = YES;
NSMutableArray *viewCons = [[[self navigationController]viewControllers] mutableCopy];
[viewCons removeLastObject];
[viewCons addObject:_landscape];
[[self navigationController]setViewControllers:viewCons animated:NO];
}
}
Worst part is it works flawlessly on the ipad 2 with the layer active, but ipad 3 cant seem to handle it. It even seems that the things i do with animation on ipad 2 (which works), cant be handle on the ipad 3. E.g. i made my own tableview header cells / tableview cells, and they also lag if i use them on ipad 3.
Any help would be appreciated!
I added some transparent images instead and its running smooth.
Still, if anyone know why this does not work, i would like to know.
Had to find this solution, because i have a deadline :).
And thanks for the comment Michael!