is groupTableViewBackgroundColor deprecated on iOS 6?

后端 未结 9 1376
-上瘾入骨i
-上瘾入骨i 2020-11-28 09:56

I was just testing my app with iOS 6.0 and Xcode 4.5GM and I have set up a view like this:

[self.view setBackgroundColor:[UIColor groupTableViewBackgroundCol         


        
相关标签:
9条回答
  • 2020-11-28 10:12

    You may have difficult time to locate the view if you use storyboard and have many views. You can click on "Show the Version editor" button the right top corner. This will change story view to XML text view. Search for "groupTableViewBackGroundColor". You should find views with this attribute.

    enter image description here

    0 讨论(0)
  • 2020-11-28 10:12

    Elaborating on @NSElvis's solution, here is the identical grouped table view background asset (it's wide enough so you don't get funny effects in landscape orientation)

    back-tableview@2x.png

    To use it, simply do

    [YOUR_VIEW setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"back-tableview"]]];
    
    0 讨论(0)
  • 2020-11-28 10:14

    First, add this to your viewDidLoad:

    self.tableView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"tableViewBackground.png"]];
    

    OR

    self.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"tableViewBackground.png"]];
    

    Then add this images to your app:

    tableViewBackground.png

    tableViewBackground.png

    tableViewBackground@2x.png

    tableViewBackground@2x.png

    0 讨论(0)
  • 2020-11-28 10:14

    In iOS6 SKD, comments in UIInterface.h suggest the following:

    Group style table view backgrounds can no longer be represented by a simple color. If you want to have a background in your own view that looks like the table view background, then you should create an empty table view and place it behind your content.

    This method will be deprecated during the 6.0 seed program

    A simple solution is to set the background with equivalent RGB values:

    [self.view setBackgroundColor:[UIColor colorWithRed:215.0/255.0 green:217.0/255.0 blue:223.0/255.0 alpha:1.0]];
    

    You can them set the view background to color to White or whatever you like in the xib to suppress the warning.

    0 讨论(0)
  • 2020-11-28 10:20

    This method will be deprecated during the 6.0 seed program If you want to have a background in your own view that looks like the table view background, then you should create an empty table view and place it behind your content.

    0 讨论(0)
  • 2020-11-28 10:25

    It's good idea to use standard methods for previous iOs versions. So I improved solution of James Boutcher:

    + (void)setBackgroundColorForTableView:(UITableView*) tableView
    {
        UIColor* color = [UIColor whiteColor];
        NSString* version = [[UIDevice currentDevice] systemVersion];
        if([version floatValue] < 6.0)
        {
            tableView.backgroundColor = color;
        }
        else
        {
            tableView.backgroundView = nil;
            UIView* bv = [[UIView alloc] init];
            bv.backgroundColor = color;
            tableView.backgroundView = bv;
            [bv release];
        }
    }
    
    0 讨论(0)
提交回复
热议问题