【发布时间】:2020-02-11 22:41:39
【问题描述】:
我有一个带有标签的表格视图单元格。在单元格的 xib 文件中,我在此标签上设置了一个小字体。在我的cellForRow 方法中,我将标签的属性文本属性设置为使用大字体的某个字符串。当我的视图控制器加载时,它最初使用 xib 中指定的小字体。当我将单元格滚动出视图并将其滚动回视图(即重新加载单元格)时,将使用正确的大字体。我怎样才能让它在第一次加载时也采用正确的字体?
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
//initialize/dequeue cell from table
[cell configureLabelWith:[[NSAttributedString alloc] initWithString:@"Hi!"
attributes:@{NSFontAttributeName : [UIFont systemFontOfSize:24.0]}];
- (void)configureLabelWith:(NSAttributedString *)title {
self.label.attributedText = title;
【问题讨论】:
标签: objective-c uitableview xib nsattributedstring