我試圖複製在節首標,在這個圖所示:頭在部分
我嘗試添加標籤同一視圖內的分隔線。 到目前爲止,我有這個代碼不工作在所有...
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
CGRect sepFrame = CGRectMake(0, 50-1, 320, 1);
UIView *customView = [[UIView alloc] initWithFrame:sepFrame];
customView.backgroundColor = [UIColor colorWithWhite:224.0/255.0 alpha:1.0];
UILabel *sectionHeader = [[UILabel alloc] initWithFrame:CGRectNull];
sectionHeader.backgroundColor = [UIColor whiteColor];
sectionHeader.textAlignment = NSTextAlignmentCenter;
sectionHeader.font = [UIFont boldSystemFontOfSize:16];
sectionHeader.textColor = [UIColor colorWithRed:(66/255.0) green:(139/255.0) blue:(18/255.0) alpha:1] ;
//sectionHeader.text = [NSString stringWithFormat:@"Section %d", section];
switch (section) {
case 0:
sectionHeader.text =NSLocalizedString(@"ACTIVO", nil) ;
[customView addSubview:sectionHeader];
break;
case 1:
sectionHeader.text = NSLocalizedString(@"PASSIVO",nil);
[customView addSubview:sectionHeader];
break;
}
return customView;
}
任何幫助將提前大加讚賞,因爲我是新來的IOS,謝謝。
爲你的'UILabel'對象提供一些框架 –
請詳細說明:) – Bruno
你的'sectionHeader'沒有任何框架。爲'sectionHeader'設置一些幀值 –