我有一個長的文本字符串,我送入一個UILabel
用於顯示。該UILabel
動態設置爲文本單線顯示爲垂直中心對準
specialities1 =[[UILabel alloc]init];
[specialities1 setFrame:CGRectMake(124,218,size8.width, size8.height)];
specialities1.backgroundColor=[UIColor clearColor];**strong text**
specialities1.lineBreakMode=UILineBreakModeClip;
specialities1.font=[UIFont fontWithName:@"Helvetica-Bold" size:14];
specialities1.text=[NSString stringWithFormat:@"%@ ",temp ];
specialities1.textAlignment=UITextAlignmentRight;
[specialities1 setNumberOfLines:0];
[specialities1 sizeToFit];
[testscroll addSubview:specialities1];
我的問題是,如果文本中只包含一行則顯示爲垂直居中對齊提供了足夠的空間。該對齊與我前面的相應標籤不匹配。
如果您在iOS6的工作,然後用'NSTextAlignmentRight'而不是'UITextAlignmentRight'。 – Krunal
試過沒有用,雖然我使用所有的比對(左,右,中)在輸出 – user1986984