2015-01-21 55 views
0

我添加了一個RefreshControl來查看長標題文本,但是這個標題被隱藏了一些詞。Swift如何在2行中添加UIRefreshControl的標題文本

override func viewDidLoad() 
    { 
     super.viewDidLoad() 

     self.refreshControl = UIRefreshControl() 
     self.refreshControl.attributedTitle = NSAttributedString(string: "Last Updated at Some time...Pull to refersh your content") 
     self.refreshControl.addTarget(self, action: "refresh:", forControlEvents: UIControlEvents.ValueChanged) 
     self.tableView.addSubview(refreshControl) 
    } 
+0

它是如何初始化,即已經'UIRefreshControl'一幀? – 2015-01-21 10:45:31

回答

1

您需要找到UIRefreshControl的UILabel並將行數設置爲0以允許多行。之後,您可以添加\n來設置換行符。 (我沒有測試此代碼,檢查是否獲得的UILabel的方法是正確的,也許你需要改變它。我會在稍後更新)

var titleLabel = self.refreshControl.subviews.firstObject.subviews.lastObject 

if(titleLabel != nil){ 
    titleLabel.numberOfLines = 0 
    var title = "Last Updated at Some time... \nPull to refersh your content" 
    self.refreshControl.attributedTitle = NSAttributedString(string: title) 
} 
+0

我找不到任何答案如何做標題插入UILabel。 – Sonrobby 2015-01-22 02:26:51

相關問題