많은 줄이있는 UILabel이 있습니다. 줄 수는 런타임에 달려 있습니다.xcode의 UILabel에서 UILinebreakmode가 작동하지 않습니까?
가내가 그것을 어떻게
-(void)viewDidLoad
{
NSString *[email protected]"";
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
을 를 얻을 수 있습니다 :이 코드는
하지만 내 UILineBreakmode가 제대로 작동하지 않습니다 ..?
'temp'의 정의는 어디에 있습니까? 예상되는 문자열에'temp'를 설정하고 예상 한 것을 성공적으로 얻습니다. – sunkehappy
나는 유 I이 작성해야 좀 ... – Honey