1. 程式人生 > >根據螢幕大小自適應字型大小

根據螢幕大小自適應字型大小

    auto winSize = Director::getInstance()->getWinSize();
    
    float fontSize_title = 35;
    if (winSize.height <= 960.0f) {
        fontSize_title = 25;
    }else if (winSize.height < 1140.0f && winSize.height > 960.0f)
    {
        fontSize_title = 30;
    }else{
        fontSize_title = 40;
    }

    return fontSize_title;