ios繪制文字
[string drawInRect:CGRectMake(50, 50, 400, 300)withFont:fount lineBreakMode: alignment:NSTextAlignmentCenter];
方法已經(jīng)不提倡使用此方法
IOS 8 中使用這個方法 : [string drawInRect: withAttributes:;
#pragma mark 繪制文字(中文豎排)
- (void)drawText2:(CGContextRef )context
{
NSString *string = @"啊的發(fā)生短發(fā)短發(fā)";
//查看所有字體
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];
}