• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

ios - UITableViewCell 显示混合字体

[复制链接]
菜鸟教程小白 发表于 2022-12-11 22:15:20 | 显示全部楼层 |阅读模式 打印 上一主题 下一主题

由于某种原因,我的 UITableViewCell 显示混合字体。这是一个演示我的意思的屏幕截图:

Mixed fonts on a single UITableViewCell

注意每一行的最后一个数字是错误的字体。根据我的测试,哪个字符被弄乱有点随机,所以不要因为它是这个屏幕截图中的最后一个字符而让你失望。

这是我设置字体的代码:

- (void)tableViewUITableView *)tableView willDisplayCellUITableViewCell *)cell forRowAtIndexPathNSIndexPath *)indexPath {
    UIImageView *iv;

    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
        [[cell textLabel] setFont: [UIFont fontWithName"BangBang" size: 36.0]];
        [[cell detailTextLabel] setFont: [UIFont fontWithName"BangBang" size: 32.0]];
        iv = [[UIImageView alloc] initWithImage:[UIImage imageNamed: @"woodTableRow~ipad.png"]];
    } else {        
        [[cell textLabel] setFont: [UIFont fontWithName"BangBang" size: 22.0]];
        [[cell detailTextLabel] setFont: [UIFont fontWithName"BangBang" size: 22.0]];
        iv = [[UIImageView alloc] initWithImage:[UIImage imageNamed: @"woodTableRow.png"]];
    }

    [cell setBackgroundView: iv];
    [iv release];

    cell.textLabel.textColor = [UIColor blackColor];
    [[cell textLabel] setShadowColor: [UIColor whiteColor]];
    [[cell textLabel] setShadowOffset: CGSizeMake(0, 1)];
    [[cell textLabel] setBackgroundColor: [UIColor clearColor]];

    cell.detailTextLabel.textColor = [UIColor blackColor];
    [[cell detailTextLabel] setShadowColor: [UIColor whiteColor]];
    [[cell detailTextLabel] setShadowOffset: CGSizeMake(0, 1)];
    [[cell detailTextLabel] setBackgroundColor: [UIColor clearColor]];

    switch (indexPath.row) {
        case ScoreRow:
            [[cell textLabel] setText: @"Score"];
            [[cell detailTextLabel] setText: @"1,234"];
            break;
        case TimeRow:
            [[cell textLabel] setText: @"Time"];
            [[cell detailTextLabel] setText: @"0:39"];
            break;
        default:
            [[cell textLabel] setText: @""];
            [[cell detailTextLabel] setText: @""];
            break;
    }
}

这对我来说毫无意义。有人可以帮忙吗?

更新:

我应该注意,我已经查看了这两个 StackOverFlow 问题,但都没有帮助:

UITableViewCell Font Not Changing

What is -[UITableViewDelegate willDisplayCell:forRowAtIndexPath:] for?



Best Answer-推荐答案


代码看起来不错,所以我怀疑它是一个不完整的字体实现。

关于ios - UITableViewCell 显示混合字体,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9813056/

回复

使用道具 举报

懒得打字嘛,点击右侧快捷回复 【右侧内容,后台自定义】
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关注0

粉丝2

帖子830918

发布主题
阅读排行 更多
广告位

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap