IOS绘制文字

作者: 大玲_ | 来源:发表于2015-04-21 21:40 被阅读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];
    }
    
    

    相关文章

      网友评论

        本文标题:IOS绘制文字

        本文链接:https://www.haomeiwen.com/subject/mceufttx.html