简体   繁体   English

在集合视图单元格中更改文本NSString的大小

[英]Changing size of text NSString in collection view cell

I have text in collection cell. 我在收集单元中有文字。 How can I change size of the text which is NSString? 如何更改NSString文本的大小? I've tried something like 我已经尝试过类似

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

But it's not allowed, it says Property 'font' not found on object of type 'NSString' 但这是不允许的,它说在'NSString'类型的对象上找不到属性'font'

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

cell.author.text = detailData.author;

I think, this: 我认为这:

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

should be, this: 应该是这样的:

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

由于NSString没有字体信息(仅body = text),因此您必须在显示该字体的对象(作者)中指定字体。

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

用以下代码替换

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

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

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