我在标签的文本中有一个带有符号的两个单词的字符串,类型为“&”或“/”,如何将第一个带有符号的字符串放在第一行,第二个字符串放在第二行?
这是代码
if(self.labelTitle.text.length> self.labelTitle.bounds.size.width){
self.labelTitle.numberOfLines =2;
if([self.labelTitle.text rangeOfString:@"&"].location != NSNotFound){
NSArray * separateString = [self.labelTitle.text componentsSeparatedByString:@"&"];
NSString * firstString =[separateString objectAtIndex:0];
NSString *secondString =[separateString objectAtIndex:1];
self.labelTitle.text = firstString;
self.labelTitle.text = secondString;
}else if ([self.labelTitle.text rangeOfString:@"/"].location != NSNotFound){
//.....
}
}
我哪里错了?