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

最后編輯于
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。

推薦閱讀更多精彩內容