iOS中使用自定义字体
2014-09-15 08:48
309 查看
1、确定你的项目工程的Resources下有你要用的字体文件(.ttf或者.odf)。
2、然后在你的工程的Info.plist文件中新建一行,添加key为:UIAppFonts,类型为Array或Dictionary都行,在UIAppFonts下再建立一个键值对,key为:Item 0,添加Value为XXX.ttf(字体的名字,string型),可以添加多个,使用的时候写对应字体名字就行。
3、在你的项目里要用字体的时候 xx.font = [UIFont fontWithName:@"XXX" size:20.0],这样就可以了。
Ios代码
- (void)viewDidLoad {
NSString *imageName = @"grid.png";
UIImageView * imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:imageName]];
imageView.frame = CGRectMake(20, 20, 250, 250);
UILabel *test = [[UILabel alloc] init];
test.frame = CGRectMake(95, 215, 200, 50);
test.font=[UIFont fontWithName:@"HAKUYOGuiFanZi3500" size:30];
test.text = @"原始图片";
test.backgroundColor = [UIColor clearColor];
[imageView addSubview:test];
[test release];
[self.view addSubview:imageView];
[imageView release];
}
2、然后在你的工程的Info.plist文件中新建一行,添加key为:UIAppFonts,类型为Array或Dictionary都行,在UIAppFonts下再建立一个键值对,key为:Item 0,添加Value为XXX.ttf(字体的名字,string型),可以添加多个,使用的时候写对应字体名字就行。
3、在你的项目里要用字体的时候 xx.font = [UIFont fontWithName:@"XXX" size:20.0],这样就可以了。
Ios代码
- (void)viewDidLoad {
NSString *imageName = @"grid.png";
UIImageView * imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:imageName]];
imageView.frame = CGRectMake(20, 20, 250, 250);
UILabel *test = [[UILabel alloc] init];
test.frame = CGRectMake(95, 215, 200, 50);
test.font=[UIFont fontWithName:@"HAKUYOGuiFanZi3500" size:30];
test.text = @"原始图片";
test.backgroundColor = [UIColor clearColor];
[imageView addSubview:test];
[test release];
[self.view addSubview:imageView];
[imageView release];
}
相关文章推荐
- iOS中使用自定义字体
- ios 使用自定义字体
- iOS使用自定义字体的方法(内置和任意下载ttf\otf\ttc字体文件)
- iOS上使用自定义ttf字体
- iOS使用自定义字体
- IOS使用自定义字体
- iOS上使用自定义ttf字体
- iOS使用自定义字体的方法(内置和任意下载ttf\otf\ttc字体文件)
- iOS中使用自定义ttf/ttc字体,以及cocosbuilder中指定字体的方法
- iOS上使用自定义ttf字体
- iOS使用自定义字体 两种方法
- iOS中使用自定义字体
- iOS使用自定义字体
- iOS使用自定义字体
- IOS 设置使用自定义字体(Xcode4)
- ios中使用自定义的字体
- iOS 如何使用自定义字体
- IOS(xcode)程序中使用自定义字体的方法
- iOS使用自定义字体 两种方法
- ios 使用自定义字体