iOS 以编程方式更改字体大小不起作用

标签 ios objective-c uitableview

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.backgroundColor = [UIColor clearColor];
        if ([[UIDevice currentDevice].systemVersion floatValue] < 7.0f) {
            self.textLabel.backgroundColor = [UIColor whiteColor];
        }

        _topUserNewName= [[UILabel alloc] init];
        _topUserNewName.textAlignment = NSTextAlignmentLeft;
        _topUserNewName.backgroundColor = [UIColor clearColor];
        _topUserNewName.font = [UIFont fontWithName:@"HelvaticaNeue-Regular" size:5.0];
        _topUserNewName.textColor = [UIColor colorWithRed:(47/255.0) green:(55/255.0) blue:(65/255.0) alpha:1];
        _topUserNewName.frame = CGRectMake(66, 8, 215, 21);


        _topUserName= [[UILabel alloc] init];
        _topUserName.textAlignment = NSTextAlignmentLeft;
        _topUserName.backgroundColor = [UIColor clearColor];
        _topUserName.font = [UIFont fontWithName:@"HelvaticaNeue-Regular" size:10.0];
        _topUserName.textColor = [UIColor colorWithRed:(145/255.0) green:(212/255.0) blue:(210/255.0) alpha:1];
        _topUserName.frame = CGRectMake(66, 37, 210, 21);


        [self.contentView addSubview:_topUserNewName];
        [self.contentView addSubview:_topUserName];


        self.selectionStyle = UITableViewCellSelectionStyleNone;
    }
    return self;
}

此代码在我的表格单元格类中。我想在这里以编程方式更改字体大小,当我更改大小时没有任何变化? 我在谷歌上研究过这条规则是正确的但没有任何想法?

最佳答案

名称 HelveticaNeue-Regular 实际上并不存在。这应该是 [UIFont fontWithName:@"HelvaticaNeue"size:10.0];

您可以在此处查看所有字体名称的列表:http://iosfonts.com/

关于iOS 以编程方式更改字体大小不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28648095/

相关文章:

objective-c - 将文本从 uitextview 绘制为 pdf

ios - iOS 的事件处理 - 如何 hitTest :withEvent: and pointInside:withEvent: are related?

objective-c - 将 NSTableView 滚动到选择

iphone - block 和内存释放问题

ios - 如何从单元格调用父 TableView 方法?

ios - 重用自定义 tableViewCell 单元格中的隐藏按钮 [ios]

ios - Swift performSegueWithIdentifier 延迟

ios - 手动布局中的自动布局

ios - 检测 iPhone 底部的凹凸

iphone - 将表格 View 和导航控件添加到现有基于 View 的应用程序