Acabo de empezar a jugar con la plantilla de vista de detalles maestros en Xcode 4.3 y estoy tratando de cambiar el color de fondo de maestro y establecerlo en un degradado de color. Aquí es lo que he intentado:iOS UITableView: asignar color de fondo como degradado usando CAGradientLayer
Colors.m
#import "Colors.h"
@implementation Colors
+ (UIColor *) navigationMenuGradientTop
{
return [UIColor colorWithRed:213.0f/255.0f green:91.0f/255.0f blue:92.0f/255.0f alpha:1.0f];
}
+ (UIColor *) navigationMenuGradientBottom
{
return [UIColor colorWithRed:188.0f/255.0f green:0.0f/255.0f blue:1.0f/255.0f alpha:1.0f];
}
+ (CAGradientLayer *) navigationMenuGradient
{
NSArray *colors = [NSArray arrayWithObjects:(id)self.navigationMenuGradientTop, self.navigationMenuGradientBottom, nil];
CAGradientLayer *gradientLayer = [CAGradientLayer layer];
gradientLayer.colors = colors;
return gradientLayer;
}
@end
MasterViewController.m
import "Colors.h"
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell"];
CAGradientLayer *bgLayer = [Colors navigationMenuGradient];
bgLayer.frame = tableView.bounds;
[tableView.layer insertSublayer:bgLayer atIndex:0];
return cell;
}
Tras ejecutar me sale el siguiente error en main
- Thread 1: EXC_BAD_ACCESS (code=1, address=0xxxxxxxx)
int main(int argc, char *argv[])
{
@autorelasespool {
return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
}
}
I han agregado el marco QuartzCore al proyecto también . ¿Qué me estoy perdiendo aquí? y en qué dirección debo ir cuando ocurren dichos errores (porque la compilación tuvo éxito, la aplicación parece haberse bloqueado aquí)?
posible duplicado de [gradientes en UIView y UILabels en iPhone] (http://stackoverflow.com/questions/422066/gradients-on-uiview-and-uilabels-on-iphone) –