iMeMyself
iMeMyself

Reputation: 1649

tableview background color is not correct, wrong color floats behind cell

What i have in code: class inherited from UITableViewController myVC: UITableViewController have used xib i.e no dataSource and tableviewDelegates in .m, tableView is of kind Grouped and cell have white color i have set background in following way in viewDidLoad

 [self.tableView setBackgroundView:Nil];
    [self.tableView setBackgroundColor:[UIColor colorWithPatternImage: [UIImage imageNamed: @"App_Background"]]];

also tried the backgroundView

 UIImageView *imgbg = [[UIImageView alloc]initWithFrame:self.tableView.frame];
    imgbg.image =  [UIImage imageNamed: @"App_Background"];
    [self.tableView setBackgroundView:imgbg];

Problem: left and right margin of cell have different color problem image inclosed

background floation cell is red arrowed for the blank table image is correct and this is how its required to be

blank table bg is correct required bgrequired bg of table is somewhat like thisalso tried clearcolor for tableCell, even then blue floating cell bg is not changed

Thanks In Advance

Upvotes: 1

Views: 387

Answers (2)

iMeMyself
iMeMyself

Reputation: 1649

after trying all i removed XIb and made myVC to inherit from ViewController :UIViewController and created tableView programatically and set it backgroundColor as clearcolor and BGView Nil , setting the viewBackGround as the image i need , it worked

but i still wonder, why it dint worked using XIB or inheriting from UITableViewController

Upvotes: 1

user2545330
user2545330

Reputation: 408

Try this:

UIView *background = [[UIView alloc] initWithFrame:self.tableView.frame];
background.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"App_Background.png"]];
self.tableView.backgroundView = background;

Hope it will help!

Upvotes: 1

Related Questions