Guest User

Untitled

a guest
Jul 20th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.73 KB | None | 0 0
  1. UIView *customTitleView = [ [UIView alloc] initWithFrame:CGRectMake(10, 0, 300, 44)];
  2.  
  3. UILabel *titleLabel = [ [UILabel alloc] initWithFrame:CGRectMake(0, 0, 300, 44)];
  4.  
  5. titleLabel.text = @"<Title string here>";
  6.  
  7. titleLabel.textColor = [UIColor whiteColor];
  8.  
  9. titleLabel.backgroundColor = [UIColor clearColor];
  10.  
  11. [customTitleView addSubview:titleLabel];
  12.  
  13. -(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
  14.  
  15. UIView *customTitleView = [ [UIView alloc] initWithFrame:CGRectMake(10, 0, 300, 44)];
  16.  
  17. UILabel *titleLabel = [ [UILabel alloc] initWithFrame:CGRectMake(0, 0, 300, 44)];
  18.  
  19. titleLabel.text = @"<Title string here>";
  20.  
  21. titleLabel.textColor = [UIColor whiteColor];
  22.  
  23. titleLabel.backgroundColor = [UIColor clearColor];
  24.  
  25. [customTitleView addSubview:titleLabel];
  26.  
  27. return customTitleView;
  28.  
  29. }
  30.  
  31. -(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
  32. return 44;
  33. }
  34.  
  35. -(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
  36. {
  37. NSString *sectionTitle = [self tableView:tableView titleForHeaderInSection:section];
  38. if (sectionTitle == nil) {
  39. return nil;
  40. }
  41.  
  42. UILabel *label = [[UILabel alloc] init];
  43. label.frame = CGRectMake(20, 8, 320, 20);
  44. label.backgroundColor = [UIColor clearColor];
  45. label.textColor = [UIColor whiteColor];
  46. label.shadowColor = [UIColor grayColor];
  47. label.shadowOffset = CGSizeMake(-1.0, 1.0);
  48. label.font = [UIFont boldSystemFontOfSize:16];
  49. label.text = sectionTitle;
  50.  
  51. UIView *view = [[UIView alloc] init];
  52. [view addSubview:label];
  53.  
  54. return view;
  55. }
  56.  
  57. - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
Add Comment
Please, Sign In to add comment