2013-07-19 29 views
0

我有一個自定義的UIButton,它有一些我動態設置的文本。限制UIButton titleText框架

問題:

如果文本變得太大,它會掩蓋一個白色的箭頭是按鈕的圖像位於最右邊的位置上:

enter image description here

當文本變得太大,白色箭頭被覆蓋,,我需要避免

實施例:

enter image description here

當前代碼:

[self.filterButton setTitle:@"All" forState:UIControlStateNormal]; 
self.filterButton.titleLabel.adjustsFontSizeToFitWidth = YES; 
self.filterButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft; 
self.filterButton.contentEdgeInsets = UIEdgeInsetsMake(0, 10, 0, 0); 
[self.filterButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; 

我曾嘗試一些方法:

  • 設置titleText幀爲%0.85按鈕幀。
  • 當前代碼
  • 試圖把它的代碼框架削減的地方開始在某個點(titleText的)

感謝您的任何指導

回答

1

你有沒有嘗試設置titleEdgeInsets而不是contentEdgeInsets

+0

這樣做,謝謝。我會盡可能接受。 –