簡體   English   中英

僅更改字體大小(而不更改字體名稱)

[英]only change font size (and not font name)

我要做的是更改字體大小。

我知道下面的語句會更改字體大小,但是它會更改字體名稱,因為我們使用的是systemFontOfSize

[UIFont systemFontOfSize: 13.0];

我知道替代選項如下所述。

[myLabel setFont:[UIFont fontWithName:@"Helvetica-Bold" size:13.0]];

但是我不想使用fontWithName,因為我在IB中進行了設置。

我不想使用字體名稱,因為我的應用程序是多語言的,因此我不想使用字體名稱。

知道如何更改字體大小而不更改字體名稱。

太糟糕了,UIFont的字體指標屬性是只讀的。 如果可以在不執行以下操作的情況下對其進行動態調整,那就太好了:

UIFont * fontFromLabel = myLabel.font;

// now we have the font from the label, let's make a new font
// with the same font name but a different size
if(fontFromLabel)
{
    // 13, or whatever size you want
    UIFont * newFontForLabel = [UIFont fontWithName: fontFromLabel.fontName size: 13.0f]; 
    if(newFontForLabel)
    {
        [myLabel setFont: newFontForLabel];
    }
}

暫無
暫無

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

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