Truemag

  • Categories
    • Tips And Tricks
    • Internet
    • PHP
    • Javascript
    • CSharp
    • SQL Server
    • Linux
  • Lastest Videos
  • Our Demos
  • About
  • Contact
  • Home
  • Write With Us
  • Job Request
Home iPhone XCode Xcode UITableView custom section header background font size

Xcode UITableView custom section header background font size

These code lines below will show how to change background color, text, font name, font size in UITableView section header when you’re building iPhone applications.

You may need to change height of UITableView Section Header to fit with the customization:

self.tableView.sectionHeaderHeight = 40;

self.tableView.sectionHeaderHeight = 40;

And add this function:

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
	NSString *title = nil;
    // Return a title or nil as appropriate for the section.
 
	switch (section) {
        case 0:
            title = @"iPhone Apps Development";
            break;
        case SPENDING_LIST:
            title = @"Android Apps Development";
            break;
        default:
            break;
    }
 
	UIView *v = [[UIView alloc] initWithFrame:CGRectMake(0, 0, tableView.bounds.size.width, 40)];
	[v setBackgroundColor:[UIColor blackColor]];
 
	UILabel *label = [[[UILabel alloc] initWithFrame:CGRectMake(10,3, tableView.bounds.size.width - 10,40)] autorelease];
	label.text = title;
	label.textColor = [UIColor colorWithRed:1.0 green:1.0 blue:1.0 alpha:0.60];
	label.font = [UIFont fontWithName:@"Arial-BoldMT" size:14];
	label.backgroundColor = [UIColor clearColor];
	[v addSubview:label];
 
	return v;
}

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section { NSString *title = nil; // Return a title or nil as appropriate for the section. switch (section) { case 0: title = @"iPhone Apps Development"; break; case SPENDING_LIST: title = @"Android Apps Development"; break; default: break; } UIView *v = [[UIView alloc] initWithFrame:CGRectMake(0, 0, tableView.bounds.size.width, 40)]; [v setBackgroundColor:[UIColor blackColor]]; UILabel *label = [[[UILabel alloc] initWithFrame:CGRectMake(10,3, tableView.bounds.size.width - 10,40)] autorelease]; label.text = title; label.textColor = [UIColor colorWithRed:1.0 green:1.0 blue:1.0 alpha:0.60]; label.font = [UIFont fontWithName:@"Arial-BoldMT" size:14]; label.backgroundColor = [UIColor clearColor]; [v addSubview:label]; return v; }

Note: you should replace [UIColor blackColor] with any UIColor you would like. You may also wish to adjust dimenstions of UIView and textColor, font, size of the UILabel.

Feb 22, 2011Hoan Huynh
iPhone Xcode set UITableView background to color or imageShell script backup all Mysql Databases in Linux
You Might Also Like:
  • iPhone Xcode set UITableView background to color or image
  • How To Track Website With Multiple Google Analytisc Accounts
  • Xcode static function/method
  • Facebook Like Button And Recommend Button With fb:like, iframe and html5
  • Show Error Message On WordPress Custom Login Template Page
  • Jquery checkbox checked
  • Get Image Width Height With JQuery And JavaScript
  • Xcode compare string example
  • Add And Get Custom Field In WordPress
  • Create Custom Update Profile Page For WordPress Users
Hoan Huynh

Hoan Huynh is the founder and head of 4rapiddev.com. Reach him at [email protected]

11 years ago iPhone XCodeiPhone, sectionHeaderHeight, UIColor, UITableView, UIView, viewForHeaderInSection800
0
GooglePlus
0
Facebook
0
Twitter
0
Digg
0
Delicious
0
Stumbleupon
0
Linkedin
0
Pinterest
Most Viewed
PHP Download Image Or File From URL
24,542 views
Notepad Plus Plus Compare Plugin
How To Install Compare Text Plugin In Notepad Plus Plus
21,885 views
Microsoft SQL Server 2008 Attach Remove Log
Delete, Shrink, Eliminate Transaction Log .LDF File
17,736 views
JQuery Allow only numeric characters or only alphabet characters in textbox
15,059 views
C# Read Json From URL And Parse/Deserialize Json
11,789 views
4 Rapid Development is a central page that is targeted at newbie and professional programmers, database administrators, system admin, web masters and bloggers.
Recent Posts
  • Things to Learn about Installingderm Loan Type S
  • Online Photo Editor – Free Photoediting Software
  • A Guide to Finding the Best Paper Sellers
  • Photoediting in Home Isn’t Hard to Do!

  • Free Photo Editor Online
Categories
  • CSharp (45)
  • Facebook Graph API (19)
  • Google API (7)
  • Internet (87)
  • iPhone XCode (8)
  • Javascript (35)
  • Linux (27)
  • MySQL (16)
  • PHP (84)
  • Problem Issue Error (29)
  • Resources (32)
  • SQL Server (25)
  • Timeline (5)
  • Tips And Tricks (141)
  • Uncategorized (647)
Recommended
  • Custom Software Development Company
  • Online Useful Tools
  • Premium Themes
  • VPS
2014 © 4 Rapid Development