开发者

Changing colour of one item in Cell Detail Text (iPhone)

I have the following code in my app which changes 开发者_运维问答the cell details text items to blue.

cell.detailTextLabel.text = [NSString stringWithFormat:@"%@, %@", 
                             info.area, info.addressOne];
cell.detailTextLabel.textColor = [UIColor colorWithRed:0x33/255.0 green:0               blue:0x99/255.0     alpha:1.0];   

Is there anyway to change the colour of the two items here independently instead of both being blue ?

Thanks,

Martin


UILabel can’t display multiple colors. You’ll need to set up a pair of labels manually and add them to the cell’s contentView. For laying them out, use NSString’s -sizeWithFont:constrainedToSize:lineBreakMode: method to get the width of the two strings and position/size the labels accordingly.


One option is to create your own cell instead of use the default style so you can have two different UILabels. That way, you can have the color be different for the two UILabels.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜