5
我使用下面的代碼來計算字符串標籤的大小。iphone:sizeWithFont方法不能識別字符串中的' n'
NSString * str = @"It's \n that \n don't \n";
CGSize size = [str sizeWithFont:[UIFont fontWithName:@"Verdana" size:12.5] forWidth:300
lineBreakMode:UILineBreakModeWordWrap];
NSLog(@"Height : %f Width : %f ",size.height,size.width);
但是id不考慮字符串中的\ n個字符來改變行。當我在標籤上顯示此字符串並將其numberOfLines屬性設置爲4或5時,標籤會考慮\ n並轉到下一行。如何從字符串中計算\ n的標籤高度。請幫幫我 。
謝謝!!!