J'ai écrit une catégorie UIColor
pour remplacer groupTableViewBackgroundColor
:
@interface UIColor (UITableViewBackground)
+ (UIColor *)groupTableViewBackgroundColor;
@end
@implementation UIColor (UITableViewBackground)
+ (UIColor *)groupTableViewBackgroundColor
{
__strong static UIImage* tableViewBackgroundImage = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
UIGraphicsBeginImageContextWithOptions(CGSizeMake(7.f, 1.f), NO, 0.0);
CGContextRef c = UIGraphicsGetCurrentContext();
[[self colorWithRed:185/255.f green:192/255.f blue:202/255.f alpha:1.f] setFill];
CGContextFillRect(c, CGRectMake(0, 0, 4, 1));
[[self colorWithRed:185/255.f green:193/255.f blue:200/255.f alpha:1.f] setFill];
CGContextFillRect(c, CGRectMake(4, 0, 1, 1));
[[self colorWithRed:192/255.f green:200/255.f blue:207/255.f alpha:1.f] setFill];
CGContextFillRect(c, CGRectMake(5, 0, 2, 1));
tableViewBackgroundImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
});
return [self colorWithPatternImage:tableViewBackgroundImage];
}
@end
Cette solution permet également de modifier l'apparence de l'arrière-plan.Ne hésitez pas à changer le code de dessin :)
Grand, Merci !! – estemendoza
Bonne idée, la vue de la table vide! – Clafou
Bit d'une suggestion laide haha, vous devriez obtenir un concepteur pour faire une image de fond serait une meilleure solution. Upvote de toute façon à cause de l'indice déprécié. – Daniel