2014-12-29 135 views
-5

我有一個稱爲homeLabel的UILabel,並且我希望此標籤可以調整其大小並在適當的時候放下新的一行...我在一個視圖控制器中創建一個音符,並且該標籤包含一個音符...我可以製作標籤多線嗎?

我這是怎麼建立鑑於沒有加載標籤:

- (void)viewDidLoad { 

    [super viewDidLoad]; 
    // Do any additional setup after loading the view from its nib. 
    [self.navigationController setNavigationBarHidden:YES]; 
    self.homeLabel.font = [UIFont fontWithName:@"Candara-Bold" size:40]; 
    self.homeLabel.text = stackTableViewController.currentTarget; 

} 

我怎樣才能讓這個插座多?

謝謝!

回答

0

設置numberOfLines爲0允許任意數量的行。

yourlabel.numberOfLines = 0; 

另外一種選擇是使用UITextView,它實際上是用於多行。

2

您可以將下面的行添加到您的代碼

self.homeLabel.numberOfLines = 0; //0 to allow any number of line or specify any number that you want to be the max number of lines 
self.homeLabel.lineBreakMode = UILineBreakModeWordWrap; 
相關問題