Change the header, footer background color of the UITableView
It is a common problem to change the header and footer background color of the UITableView. The general practice previously known is to implement Tableview:viewforheaderinsection: return a custom view where nothing is filled in and only the background color is set. But today, a more concise approach is found:
For iOS 6 and beyond, implement this new delegate function:
Copy Code code as follows:
-(void) TableView: (UITableView *) TableView Willdisplayfooterview: (UIView *) View forsection: (nsinteger) Section {
View.tintcolor = [Uicolor Clearcolor];
}
You can also change the color of the text:
Copy Code code as follows:
-(void) TableView: (UITableView *) TableView Willdisplayfooterview: (UIView *) View forsection: (nsinteger) Section
{
Uitableviewheaderfooterview *footer = (Uitableviewheaderfooterview *) view;
[Footer.textlabel Settextcolor:[uicolor Whitecolor]];
}
Modify the background picture of TableView
Modify the background picture of UITableView
1. The picture is shown as ' patternimage ' mode.
Copy Code code as follows:
Viewdidload
Self.tableView.backgroundColor = [Uicolor colorwithpatternimage:[uiimage imagenamed:@ "BackgroundImage"]];
Cellforrowatindexpath
Cell.backgroundcolor = [Uicolor Clearcolor];
In this case, the background image is tiled like a floor tile. Pull TableView background image will move, if the number of rows exceeds the height of the background picture, will then display the next picture.
2. The normal background picture.
Copy Code code as follows:
Viewdidload
self.tableview.backgroundcolor= [Uicolor Clearcolor];
Uiimageview*imageview = [[Uiimageview alloc]initwithimage:[uiimageimage named:@ "BackgroundImage"]];
Self.tableView.backgroundView = ImageView;
Cellforrowatindexpath
Cell.backgroundcolor = [Uicolor Clearcolor];
In this case, the background image does not move, that is, no matter how many rows see the same background.