Change the selected cell background colour using UIAppearance

前端 未结 3 1470
梦谈多话
梦谈多话 2020-12-20 07:43

I need to change the selected cell background colour for all the cells in my app. As I know there is a way to use UIAppearance protocol for this purposes. Is it

3条回答
  •  抹茶落季
    2020-12-20 08:42

    Using appearance proxy you can colour all cells. Don't know if you can target specific category.

    To do the colouring put following code in your AppDelegate.m file:

    Put [self customCellBackground]; in - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions

    and somewhere at the end:

    - (void)customCellBackground {
    UIView *cellBackgroundView =[[UIView alloc] init];
    cellBackgroundView.backgroundColor = [UIColor blackColor];
    [[UITableViewCell appearance] setSelectedBackgroundView:cellBackgroundView];}
    

提交回复
热议问题