21

iOS 7 のスリムなシステム フォントの名前は? のように使う方法はありUIFont systemFontOfSize:ますか?

4

4 に答える 4

27

便利なリファレンス ツールを次に示します。

http://iosfonts.com

あなたが探しているのはHelveticaNeue-LightHelveticaNeue-UltraLightです。

于 2013-09-15T20:31:32.010 に答える
22

iOS 8.2以降、以下を使用できるようになりましたUIFont.systemFontOfSize(_:CGFloat,weight:CGFloat)

UIFont.systemFontOfSize(19, weight: UIFontWeightLight)

iOS SDK には、重みの定数が用意されています。

UIFontWeightUltraLight
UIFontWeightThin
UIFontWeightLight
UIFontWeightRegular
UIFontWeightMedium
UIFontWeightSemibold
UIFontWeightBold
UIFontWeightHeavy

システム フォントを使用する場合は、iOS でシステム フォントを変更できるため、システム フォントを使用する場合は、フォント名に基づいてフォントを作成するよりも優れています (iOS 7 の Helvetica Neue や iOS 9 の San Francisco のように)。 .

于 2015-06-24T06:05:00.860 に答える
1

以下のようにUIFontの拡張機能を作成するだけです

extension UIFont {

    static func lightSystemFontOfSize(size: CGFloat) -> UIFont {

        let familyName = UIFont.systemFontOfSize(15).familyName.stringByReplacingOccurrencesOfString(" ", withString: "")

        return UIFont(name: "\(familyName)-Light", size: size)!
    }
}
于 2016-08-21T17:06:57.950 に答える
0

そのためのカテゴリを作成しました:

#import <UIKit/UIKit.h>

@interface UIFont (System)

+ (UIFont *)lightSystemFontOfSize:(CGFloat)fontSize;
+ (UIFont *)ultraLightSystemFontOfSize:(CGFloat)fontSize;

@end

#import "UIFont+System.h"

@implementation UIFont (System)

+ (UIFont *)lightSystemFontOfSize:(CGFloat)fontSize {
    return [UIFont fontWithName:@"HelveticaNeue-Light" size:fontSize];
}

+ (UIFont *)ultraLightSystemFontOfSize:(CGFloat)fontSize {
    return [UIFont fontWithName:@"HelveticaNeue-UltraLight" size:fontSize];
}

@end
于 2015-08-13T06:56:22.753 に答える