iOS之UIFont字体设置

https://www.jianshu.com/p/4835e2b408e5

http://blog.csdn.net/sunnyboy9/article/details/51241008

UIFont继承自NSObject,用于获取和设置字体信息的接口。

1.使用任意字体名来创建UIFont类实例:

[objc] view plain copy

+ (UIFont *)fontWithName:(NSString *)fontName size:(CGFloat)fontSize;

例如:

[objc] view plain copy

UIFont *font = [UIFont fontWithName:@"courer-Bold" size:[UIFont labelFontSize]];


2.获取用户偏好字体:

[objc] view plain copy

+ (UIFont *)preferredFontForTextStyle:(NSString *)styleNS_AVAILABLE_IOS(7_0);



3.以数组的形式返回已安装的字体名称:

[objc] view plain copy

+ (NSArray *)familyNames;


参考:http://blog.csdn.net/sakulafly/article/details/46368173

4.取得可用的字型集的名称。然後你可以用这些恰当的名称去取得字体名字:

[objc] view plain copy

+ (NSArray *)fontNamesForFamilyName:(NSString *)familyName;


例如:

遍历获取所有字体的名称:

for (NSString* familyin [UIFont familyNames])

{

    NSLog(@"%@", family);

    for (NSString* namein [UIFont fontNamesForFamilyName: family])

    {

        NSLog(@"  %@", name);

    }

}

设置:[UIFont fontWithName:@"OpenSans-Bold" size:20.0];


5.创建新字体,与当前字体相同,需要指定大小:

[objc] view plain copy

- (UIFont *)fontWithSize:(CGFloat)fontSize;


6.通过描述符返回字体:

[objc] view plain copy

+ (UIFont *)fontWithDescriptor:(UIFontDescriptor *)descriptor size:(CGFloat)pointSizeNS_AVAILABLE_IOS(7_0);



7.返回字体描述符:

[objc] view plain copy

- (UIFontDescriptor *)fontDescriptorNS_AVAILABLE_IOS(7_0);



[UIFontsystemFontOfSize:14weight:UIFontWeightThin]

weight取下面的值:

UIFontWeightUltraLight  - 超细字体

UIFontWeightThin  - 纤细字体

UIFontWeightLight  - 亮字体

UIFontWeightRegular  - 常规字体

UIFontWeightMedium  - 介于Regular和Semibold之间

UIFontWeightSemibold  - 半粗字体

UIFontWeightBold  - 加粗字体

UIFontWeightHeavy  - 介于Bold和Black之间

UIFontWeightBlack  - 最粗字体(理解)

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值