- 将字体文件添加到项目中:
-
在info.plist文件中添加键值对“Font provided by application",是数组类型,向其添加属性:value值为你添加的字体文件的文件名
ok ,现在可以使用添加的自定义字体了,使用方法为:
[UIFont fontWithName:@"Yuppy SC" size:20];
- 如设置一个button的文本内容和字体
self.gifButton = [[UIButton alloc]initWithFrame:CGRectMake(ScreenWidth/2-40, ScreenHeight/2-40, 80, 80)];
[self.gifButton setTitle:@"制作Gif" forState:UIControlStateNormal];
[self.gifButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
self.gifButton.titleLabel.font = [UIFont fontWithName:@"Yuppy SC" size:20];
self.gifButton.layer.cornerRadius = 40;
self.gifButton.backgroundColor = [UIColor greenColor];