IOS绘制文字

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];
}

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容