簡體   English   中英

NSButton(Cell)setFont

[英]NSButton(Cell) setFont

從10.9起, NSButtonCellsetFont方法似乎不再可用。
有什么方法(或類別)來(重新)實現它?

我不知道蘋果為什么要在按鈕上使用自己的樣式。
我想花兩天時間來設計自己的自定義按鈕的樣式(我還需要一個類別來簡單地更改按鈕的文本顏色-恥辱感)。

您可以使用NSButton -setAttributedTitle:來設置按鈕標題的樣式。

樣例代碼:

NSDictionary *attributes = @{NSForegroundColorAttributeName: [NSColor redColor], NSFontAttributeName: [NSFont userFixedPitchFontOfSize:13.0f]};
NSAttributedString *aString = [[NSAttributedString alloc] initWithString:@"Button" attributes:attributes];
[button setAttributedTitle:aString];

在此處輸入圖片說明

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM