Ios 按图像分隔detailTextLabel

Ios 按图像分隔detailTextLabel,ios,objective-c,uitableview,Ios,Objective C,Uitableview,我正在尝试这样做: 分隔符需要随标签的长度动态更改。这就是我现在拥有的 UIImageView *separator = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"Shuffle"]]; separator.frame = CGRectMake(CGRectGetMaxX(cell.detailTextLabel.frame), CGRectGetHeight(cell.frame) / 2,200, 20); [cell

我正在尝试这样做:

分隔符需要随标签的长度动态更改。这就是我现在拥有的

UIImageView *separator = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"Shuffle"]];
separator.frame = CGRectMake(CGRectGetMaxX(cell.detailTextLabel.frame), CGRectGetHeight(cell.frame) / 2,200, 20);
[cell addSubview:separator];

图像放在那里,但它不会像我想象的那样动态变化。

如果您只需要一个•,只需将标签文本设置为

cell.detailTextLabel.text = [NSString stringWithFormat:@"ARTIST: %@ • LENGTH: %@", artistName, formattedTimeAsString];

当然,如果您支持多种语言,您可能必须使用NSLocalizedString

图像中的分隔符是什么?您可以使用“•”作为分隔符,或者可以使用
NSAttributedString
NSTextAttachment
。进行研究,因为StackOverFlow中对此有疑问?我的错误。我想只要给你两个关键词(
NSAttributedString
NSTextAttachment
),就足够了。这里有一个链接:你在哪里调用代码?