我必須使用MTLabel類來進行UILabel的行間距。關於使用MTLabel設備旋轉的麻煩
(refered示例代碼:https://github.com/Tuszy/MTLabel)
但是一些問題存在。
我正在製作iPad應用程序。這個應用程序可以旋轉 - 橫向或縱向。
我把UILabel和MTLable對象放在沒有IB的視圖上。
只要改變設備的方向,文字的寬度也會改變。
這個結果不是我想要的。
我的代碼:
#import "MTLabel.h"
。
- (void)viewDidLoad
{
[super viewDidLoad];
MTLabel *TitleFont = [[MTLabel alloc] initWithFrame:CGRectMake(255, 60, 270, 60)];
[TitleFont setFont:[UIFont fontWithName:@"Arial" size:30.0]];
TitleFont.backgroundColor = [UIColor greenColor];
TitleFont.text = @"Happy! - 1";
TitleFont.autoresizingMask = UIViewAutoresizingFlexibleTopMargin& UIViewAutoresizingFlexibleLeftMargin&UIViewAutoresizingFlexibleRightMargin;
TitleFont.autoresizingMask= UIViewAutoresizingFlexibleWidth;
[self.view addSubview:TitleFont];
//----------------------
UILabel *TitleFont2 = [[UILabel alloc] initWithFrame:CGRectMake(255, 120, 270, 60)];
[TitleFont2 setFont:[UIFont fontWithName:@"Arial" size:30.0]];
TitleFont2.backgroundColor = [UIColor orangeColor];
TitleFont2.text = @"Happy! - 2";
TitleFont2.autoresizingMask = UIViewAutoresizingFlexibleTopMargin& UIViewAutoresizingFlexibleLeftMargin&UIViewAutoresizingFlexibleRightMargin;
TitleFont2.autoresizingMask= UIViewAutoresizingFlexibleWidth;
[self.view addSubview:TitleFont2];
}
結果: 1)肖像圖片:
2)景觀形象:
如果我使用UILabel類,沒問題! 但我不得不MTLabel類行間距的UILabel。
請幫我...謝謝。