Created
April 9, 2012 19:49
-
-
Save dchohfi/2346111 to your computer and use it in GitHub Desktop.
tableView:viewForHeaderInSection: like the default header view
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 | |
{ | |
float width = tableView.bounds.size.width; | |
int fontSize = 18; | |
int padding = 10; | |
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, width, fontSize)]; | |
view.backgroundColor = [UIColor colorWithWhite:0 alpha:0]; | |
view.userInteractionEnabled = YES; | |
view.tag = section; | |
UIImageView *image = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"PlainTableViewSectionHeader.png"]]; | |
image.contentMode = UIViewContentModeScaleAspectFit; | |
[view image]; | |
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(padding, 2, width - padding, fontSize)]; | |
label.text = @"Texto"; | |
label.backgroundColor = [UIColor clearColor]; | |
label.textColor = [UIColor whiteColor]; | |
label.shadowColor = [UIColor darkGrayColor]; | |
label.shadowOffset = CGSizeMake(0,1); | |
label.font = [UIFont boldSystemFontOfSize:fontSize]; | |
[view addSubview:label]; | |
return view; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
What [view image] means?