Created
December 2, 2011 18:54
-
-
Save ecpplus/1424388 to your computer and use it in GitHub Desktop.
UITableView のヘッダのテキストを変更(任意のUIViewに変更可)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-(UIView*) tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section { | |
UIView *titleWrapper = [[[UIView alloc] initWithFrame:CGRectMake(0, 0, 120, 40)] autorelease]; | |
UILabel *titleLabel = [[[UILabel alloc] initWithFrame:CGRectMake(15, 15, 100, 20)] autorelease]; | |
titleLabel.backgroundColor = [UIColor clearColor]; | |
titleLabel.textColor = [UIColor redColor]; | |
titleLabel.font = [UIFont boldSystemFontOfSize:18]; | |
switch(section) { | |
case 0: | |
titleLabel.text = @"アプリ設定"; | |
break; | |
case 1: | |
titleLabel.text = @"プロフィール設定"; | |
break; | |
case 2: | |
titleLabel.text = @"初期化"; | |
break; | |
} | |
[titleWrapper addSubview:titleLabel]; | |
return titleWrapper; | |
} | |
-(CGFloat) tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section { | |
return 20; | |
} | |
-(CGFloat) tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section { | |
return 44; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment