adding background image to uitable causes tiling on table cells

Discussion in 'iOS Programming' started by johnmerlino, Dec 7, 2011.

  1. johnmerlino macrumors member

    Joined:
    Oct 22, 2011
    #1
    Hey all,

    When my table view loads, on the viewDidLoad I add this line of code:

    Code:
                  self.tableView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"unit_list_bg.png"]];
    
    
    That line of code correctly displays the image on the table view but it also tiles the image on each of the cells, which is not what I want, as shown on the image attached to this post.

    I just want the background image to be the background of the table not each table cell.

    Also note that I originally had the background image applied to the view but the problem with that is the blue navigation bar on top clipped part of the image:

    Code:
                self.parentViewController.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"unit_list_bg.png"]];
                self.tableView.backgroundColor = [UIColor clearColor];
    
    thanks for response
     

    Attached Files:

  2. jnoxx macrumors 65816

    jnoxx

    Joined:
    Dec 29, 2010
    Location:
    Aartselaar // Antwerp // Belgium
    #2
    You are using a UIColor attribute for images. I know that it's possible.. but just, why? :p
    I think you don't really understand the layers yet in an iOS frontend.
    And to get a background on the tableview, just set it on the view behind the tableview, and make the tableview.backgroundcolor -> UIColor clearColor.
    Since we don't even know what you are exactly trying to achieve, I cant give tips actually >;<
     
  3. PhoneyDeveloper macrumors 68030

    PhoneyDeveloper

    Joined:
    Sep 2, 2008
  4. johnmerlino, Dec 8, 2011
    Last edited: Dec 8, 2011

    johnmerlino thread starter macrumors member

    Joined:
    Oct 22, 2011
    #4
    On the original question, I mentioned I tried that. But the blue navigation bar on the top eclipses it.

    I kind of resolved this like this:

    self.tableView.backgroundView = [[UIImageView alloc] initWithImage:[[ UIImage imageNamed:mad:"bg.png"] stretchableImageWithLeftCapWidth:20 topCapHeight:0]];
     

Share This Page