Iphone UITableViewCell显示多种字体
我想在uitableviewcell中以类似于iPhone通讯簿的不同字体显示两个单词。Iphone UITableViewCell显示多种字体,iphone,objective-c,uitableview,Iphone,Objective C,Uitableview,我想在uitableviewcell中以类似于iPhone通讯簿的不同字体显示两个单词。 例:JohnBuchanan您可以使用两个UILable,也可以使用绘制NSAttribute字符串 编辑: 您可以使用动态更改UILabel大小 CGSize expectedLabelSize = [titleLabel.text sizeWithFont:titleLabel.font]; titleLabel.frame = CGRectMake(xBase, yBase, expectedLab
例:JohnBuchanan您可以使用两个UILable,也可以使用绘制NSAttribute字符串 编辑: 您可以使用动态更改UILabel大小
CGSize expectedLabelSize = [titleLabel.text sizeWithFont:titleLabel.font];
titleLabel.frame = CGRectMake(xBase, yBase, expectedLabelSize.width, expectedLabelSize.height);
杰克
使用cell.textlab.text和cell.textlab.DetailText。。
这是一个单元格中的两个标签。对于每个标签,创建字体并应用于该标签的字体属性
+ (UIFont *)fontWithName:(NSString *)fontName size:(CGFloat)fontSize
创建自定义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;
}
但是标签的大小是固定的吗??我想显示与iPhone地址簿中相同的内容。