UIFont.h
2019-06-26 本文已影响0人
zhYx_
#if USE_UIKIT_PUBLIC_HEADERS || !__has_include(<UIKitCore/UIFont.h>)
//
// UIFont.h
// UIKit
//
// Copyright (c) 2007-2018 Apple Inc. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <CoreGraphics/CoreGraphics.h>
#import <UIKit/UIKitDefines.h>
#import <UIKit/UIFontDescriptor.h>
@class UITraitCollection;
NS_ASSUME_NONNULL_BEGIN
#pragma mark - 字体 Class
#pragma mark -
NS_CLASS_AVAILABLE_IOS(2_0) @interface UIFont : NSObject <NSCopying>
#pragma mark |实例化|
// 指定风格
+ (UIFont *)preferredFontForTextStyle:(UIFontTextStyle)style NS_AVAILABLE_IOS(7_0);
// 指定风格和字体特征
+ (UIFont *)preferredFontForTextStyle:(UIFontTextStyle)style compatibleWithTraitCollection:(nullable UITraitCollection *)traitCollection NS_AVAILABLE_IOS(10_0) __WATCHOS_PROHIBITED;
// 指定字体名和字号
+ (nullable UIFont *)fontWithName:(NSString *)fontName size:(CGFloat)fontSize;
/* 获取系统自带字体的所有字体名 */
#if UIKIT_DEFINE_AS_PROPERTIES
@property(class, nonatomic, readonly) NSArray<NSString *> *familyNames;
#else
+ (NSArray<NSString *> *)familyNames;
#endif
// 获取特定系列字体的所有字体名
+ (NSArray<NSString *> *)fontNamesForFamilyName:(NSString *)familyName;
#pragma mark |实例化|
// 指定字号的系统标准字体
+ (UIFont *)systemFontOfSize:(CGFloat)fontSize;
// 指定字号的系统加粗字体
+ (UIFont *)boldSystemFontOfSize:(CGFloat)fontSize;
// 指定字号的系统斜体字体
+ (UIFont *)italicSystemFontOfSize:(CGFloat)fontSize;
#pragma mark |实例化|
// 指定字号和字体权重
+ (UIFont *)systemFontOfSize:(CGFloat)fontSize weight:(UIFontWeight)weight NS_AVAILABLE_IOS(8_2);
// 指定字号和字体权重(等比例间距)
+ (UIFont *)monospacedDigitSystemFontOfSize:(CGFloat)fontSize weight:(UIFontWeight)weight NS_AVAILABLE_IOS(9_0);
#pragma mark |字体属性|
/// 字体系列名
@property(nonatomic,readonly,strong) NSString *familyName;
/// 字体名
@property(nonatomic,readonly,strong) NSString *fontName;
/// 点大小
@property(nonatomic,readonly) CGFloat pointSize;
/// 字体上偏移最大值
@property(nonatomic,readonly) CGFloat ascender;
/// 字体下偏移最大值
@property(nonatomic,readonly) CGFloat descender;
/// 大写字符高度
@property(nonatomic,readonly) CGFloat capHeight;
/// 小写字符高度
@property(nonatomic,readonly) CGFloat xHeight;
/// 线高
@property(nonatomic,readonly) CGFloat lineHeight NS_AVAILABLE_IOS(4_0);
/// 前导值
@property(nonatomic,readonly) CGFloat leading;
// 根据已经实例化的字体对象,再实例化一个其他属性都一样字号重新设置的字体
- (UIFont *)fontWithSize:(CGFloat)fontSize;
// 实例化与字体描述符匹配的字体
+ (UIFont *)fontWithDescriptor:(UIFontDescriptor *)descriptor size:(CGFloat)pointSize NS_AVAILABLE_IOS(7_0);
/* 获取字体的描述符 */
#if UIKIT_DEFINE_AS_PROPERTIES
@property(nonatomic, readonly) UIFontDescriptor *fontDescriptor NS_AVAILABLE_IOS(7_0);
#else
- (UIFontDescriptor *)fontDescriptor NS_AVAILABLE_IOS(7_0);
#endif
@end
NS_ASSUME_NONNULL_END
#else
#import <UIKitCore/UIFont.h>
#endif