ios绘制文字
[string drawInRect:CGRectMake(50, 50, 400, 300)withFont:fount lineBreakMode: alignment:NSTextAlignmentCenter];
方法已经不提倡使用此方法
IOS 8 中使用这个方法 : [string drawInRect: withAttributes:;
#pragma mark 绘制文字(中文竖排)
- (void)drawText2:(CGContextRef )context
{
NSString *string = @"啊的发生短发短发";
//查看所有字体
NSLog(@"%@",[UIFont familyNames]);
UIFont *fount = [UIFont fontWithName:@"Mishafi" size:20];
//NSDictionary *dict =@{NSFontAttributeName:[UIFont systemFontOfSize:18] };
[string drawInRect:CGRectMake(290, 10, 30, 440)withFont:fount lineBreakMode:NSLineBreakByCharWrapping alignment:NSTextAlignmentCenter];
}
#pragma mark 绘制文字
- (void)drawText:(CGContextRef)context
{
//英文中通常按照单词换行
NSString *string = @"hello world! hello world! hello world! hello world! hello world! hello world! hello world! hello world! hello world! hello world!";
//查看所有字体
NSLog(@"%@",[UIFont familyNames]);
UIFont *fount = [UIFont fontWithName:@"Mishafi" size:20];
//NSDictionary *dict =@{NSFontAttributeName:[UIFont systemFontOfSize:18] };
// [string drawInRect:CGRectMake(50, 50, 400, 300)withFont:fount lineBreakMode:NSLineBreakByWordWrapping alignment:NSTextAlignmentCenter];
}
网友评论