iphone - UITableView titleForSection 字体

标签 iphone xcode uitableview interface-builder nsstring

一个简单的问题,一个快速的答案(因为我没有找到任何答案):

有没有办法在 iPhone 中更改该部分标题的字体(由 titleForSection 给出)?

非常感谢!

最佳答案

谢谢贾萨里恩!你说得完全正确。

我在这里留下我的代码来帮助遇到同样问题的人:

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

   NSString *sectionTitle = @"Just a title";

    // Create label with section title
    UILabel *label = [[[UILabel alloc] init] autorelease];
    label.frame = CGRectMake(0, 0, 284, 23);
    label.textColor = [UIColor blackColor];
    label.font = [UIFont fontWithName:@"Helvetica" size:14];
    label.text = sectionTitle;
    label.backgroundColor = [UIColor clearColor];

    // Create header view and add label as a subview
    UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 100)];
    [view autorelease];
    [view addSubview:label];

    return view;
}

关于iphone - UITableView titleForSection 字体,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2450861/

相关文章:

swift - UINavigationController 中的 tvOS UITableView 导致奇怪的褪色行为(UIView.mask)

ios - 魔术记录,从UITableView中删除“第0节中的行数无效……”

iPhone API - 周围设备的蓝牙 MAC 地址?

iphone - 如何正确释放带有 NSMutableArray 成员且内部有 NSNumber 对象的对象的 NSMutableArray?

iphone - 使用iPhone视网膜图像作为iPad非视网膜图像,无需重复

objective-c - objective-c 中的方位角/方位角计算

c++ - 当一个函数可以被赋予一个 char* 或文字字符串时,声明这个函数的正确方法是什么?

ios - 嵌入式导航栏在运行时不显示。

iphone - iOS 4上的人脸检测

ios - UIViewController 中的 UITableView