Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone UITableViewCell显示多种字体_Iphone_Objective C_Uitableview - Fatal编程技术网

Iphone UITableViewCell显示多种字体

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

我想在uitableviewcell中以类似于iPhone通讯簿的不同字体显示两个单词。
例:JohnBuchanan

您可以使用两个UILable,也可以使用绘制NSAttribute字符串

编辑:

您可以使用动态更改UILabel大小

CGSize expectedLabelSize = [titleLabel.text sizeWithFont:titleLabel.font]; 
titleLabel.frame = CGRectMake(xBase, yBase, expectedLabelSize.width, expectedLabelSize.height);
杰克 使用cell.textlab.textcell.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地址簿中相同的内容。