2011-12-07 164 views
0

我已經設置了一個UIButton作爲我的導航欄的titleView。但是,無論按鈕的寬度如何,標題似乎都會被截斷。爲什麼?標題UIButton截斷

UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect]; 
[button setTitle:[[NSDate date] stringWithNSDateFormatterMediumStyle] forState:UIControlStateNormal]; 
[button setFrame:CGRectMake(0, 0, 150, 40)]; 
self.navigationItem.titleView = button; 

enter image description here

回答

1
[button setFrame:CGRectMake(0, 0, 250, 40)]; // are you sure your button is wide enough? 
+1

絕對。無論多寬,我總是會截斷! – NSExplorer

+0

我不確定,但可能是由導航欄強加的限制。你能用像12/25/11這樣的更短的格式還是更小的字體? – Rayfleck

+0

是的,這就是我最終做的。 – NSExplorer