我想在uitableviewcell中以与iPhone地址簿类似的不同字体显示两个单词。 例如:约翰·布坎南UITableViewCell显示多种字体
回答
要么你应该使用两个UILables,或者您可以使用OHAttributedLabel绘制NSAttributedString ..
编辑:
您可以使用动态改变大小的UILabel,
CGSize expectedLabelSize = [titleLabel.text sizeWithFont:titleLabel.font];
titleLabel.frame = CGRectMake(xBase, yBase, expectedLabelSize.width, expectedLabelSize.height);
感谢..这真的帮助 – Jack
@jack欢迎:) – KingofBliss
插孔 使用cell.textLabel.text和cell.textLabel.DetailText .. 这些是一个单元格中的两个标签..
对于每个标签创建字体并应用于该标签的font属性。
+ (UIFont *)fontWithName:(NSString *)fontName size:(CGFloat)fontSize
但标签的尺寸是固定的吧??我想要显示与iPhone地址簿中相同的内容。 – Jack
制作自定义的UITableViewCell。
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:CellIdentifier] autorelease];
}
//Initialize String for Displaying
//NSString *str =
UILabel *lbl;
if ([cell.contentView.subviews count] == 0) {
//Label alloc and init with frame
//lbl = [[UILabel] alloc] initWithFrame:CGRectMake(x,y,width,height)];
//Cofigure Label (text, font, etc.)
lbl.text = str;
//lbl.font = font;
//Add subview
[cell.contentView addSubview:lbl];
//Release
[lbl release];
}
else {
lbl = [cell.contentView.subviews objectAtIndex:0];
lbl.text = str; //Do only set variable value.
}
return cell;
}
谢谢.. DIS给了我一些想法..! – Jack
- 1. UITableViewCell显示混合字体
- 2. 显示具有多种格式字的显示字符串
- 3. 多种语言的多种字体
- 4. 仅在表更新后才显示UITableViewCell自定义字体
- 5. UITableViewCell中的多种颜色
- 6. UItableViewCell中的项获得多次显示
- 7. flash.text.TextFormat中的多种字体
- 8. JasperReports - 指定多种字体?
- 9. Tesseract OCR多种字体
- 10. Cufon有多种字体?
- 11. Cufon多种字体 - 如何?
- 12. UITableViewCell accessoryView不显示
- 13. 显示UItableViewcell选择
- 14. UITableViewCell字体大小不变
- 15. UITableViewCell字体大小不变
- 16. UITableViewCell不显示数据
- 17. UITableViewCell不显示UILabel在
- 18. UITableViewCell单元格不显示
- 19. 自定义UITableViewCell - 不显示
- 20. UITableViewCell上的图像显示
- 21. UITableViewCell没有刷新显示?
- 22. “的UITableViewCell”不显示标签
- 23. 如何突出显示UITableViewCell
- 24. UITableViewCell不显示文本
- 25. 的UITableViewCell ImageView的不显示
- 26. 显示UITableViewCell中多个图像上传的进度指示器
- 27. 在WP7中显示字体
- 28. 字体显示问题
- 29. Java字体显示问题
- 30. iPhone中的字体显示
检查我的编辑答案\ – KingofBliss