【问题标题】:Changing size of text NSString in collection view cell更改集合视图单元格中文本 NSString 的大小
【发布时间】:2016-10-13 07:56:20
【问题描述】:

我在集合单元格中有文本。 如何更改 NSString 文本的大小?我尝试过类似

cell.author.text.font = [UIFont systemFontOfSize:12.0];

但这是不允许的,它说 在“NSString”类型的对象上找不到属性“字体”

CollectionCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:identifier forIndexPath:indexPath];

cell.author.text = detailData.author;

【问题讨论】:

  • cell.author.font = [UIFont systemFontOfSize:12.0];

标签: ios objective-c nsstring uicollectionviewcell


【解决方案1】:

我想,这个:

cell.author.text.font = [UIFont systemFontOfSize:12.0];

应该是这样的:

cell.author.font = [UIFont systemFontOfSize:12.0];

【讨论】:

    【解决方案2】:

    由于 NSString 没有关于字体的信息(只有 body=text),您必须在显示它的对象中指定字体 - 作者。

    cell.author.font = [UIFont systemFontOfSize:12.0];
    

    【讨论】:

      【解决方案3】:
      cell.author.text.font = [UIFont systemFontOfSize:12.0];
      

      将代码替换为

      cell.author.font = [UIFont systemFontOfSize:12.0];
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2023-03-19
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2018-12-24
        • 2020-07-10
        相关资源
        最近更新 更多