iOS开发-绘制

IOS绘制文字

2015-04-21  本文已影响5614人  大玲_

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

上一篇下一篇

猜你喜欢

热点阅读