我有一个有很多行的 UILabel。行数取决于运行时。但是我的 UILineBreakmode 无法正常工作..
这是代码:
-(void)viewDidLoad
{
NSString *temp=@"";
for(int i=0;i<[arr2 count];i++)
{
temp=[temp stringByAppendingString:[[array objectAtIndex:i]objectForKey:@"Specilities"]];
temp=[temp stringByAppendingString:@","];
}
temp = [temp substringToIndex:[temp length]-1];
CGSize constraint8 = CGSizeMake(190, 2000.0f);
CGSize size8=[temp sizeWithFont:[UIFont fontWithName:@"Helvetica" size:14] constrainedToSize:constraint8 lineBreakMode:UILineBreakModeWordWrap];
specialities =[[UILabel alloc]init];
[specialities setFrame:CGRectMake(124,270,190, size8.height)];
specialities.textAlignment=UITextAlignmentLeft;
specialities.backgroundColor=[UIColor clearColor];
specialities.font=[UIFont fontWithName:@"Helvetica" size:14];
specialities.text=[NSString stringWithFormat:@"%@ ",temp ];
specialities.numberOfLines=0;
[specialities sizeToFit];
[self.view addSubview:specialities];
}
Expected result:
Family Dentistry,Dentist-
Child,Dentist-Family,
Orthodontist
The result which Im getting:
Family Dentistry,Dentist-
Child,Dentist-Family,Orthodo
ntist
我怎么才能得到它 ?