THIS
You need to set header.frame = CGRectMake(10,1, 100, 18 );
OR
Use UITableView
Data Source Method
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section { return @"Header";
Edition:
-(UIView*)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section { UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 20)]; UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(50, 2, 100, 18)]; label.text= [self.listOfHeader objectAtIndex:section]; label.backgroundColor=[UIColor clearColor]; label.textAlignment=NSTextAlignmentLeft; [view addSubview:label]; return view; }
Also add
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section { return 20; }
source share