繁体   English   中英

如何更改titleForHeaderInSection的字体颜色?

[英]How can i change the font color for titleForHeaderInSection?

这是我当前必须显示的文本,但是我似乎无法更改titleForHeaderInSection的字体颜色。

- (NSString *)tableView:(UITableView *)tableView 
                                       titleForHeaderInSection:(NSInteger)section 
{
    if(section == 0)
        return @"Information";
    if(section == 1)
        return @"Categorize Information";
    return nil;
}

我将如何更改字体颜色,例如可以是红色?

编辑:我忘了提,我没有使用Interface Builder来做到这一点。

您需要创建一个自定义UIView。 我发现最好的方法是在Interface Builder中。

。H

@interface MyViewController : UITableViewController {
    IBOutlet UIView *headerView;
}
@property (nonatomic, retain) UIView *headerView;
@end

.M

#import “MyViewController.h”
@implementation MyViewController
@synthesize headerView;

#pragma mark Table Stuff
- (UIView *)tableView:(UITableView *)tableView
                                     viewForHeaderInSection:(NSInteger)section 
{
    /* create a UIView here */
    return headerView;
}

#pragma mark Memory Management
- (void)dealloc {
    [headerView release];
    [super dealloc];
}

UITableView委托中使用:

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section

返回自定义UIView对象,您可以在其中更改所需的内容。 链接

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM