How to convert text to Image on iOS?

前端 未结 7 2281
庸人自扰
庸人自扰 2020-12-07 18:10

I am trying to write a function to convert the textfield text to an image (example). I have tried to search for an example, most of the sample also is overwrite text on imag

7条回答
  •  隐瞒了意图╮
    2020-12-07 18:38

    NSString *string = @"Some text";
    UIGraphicsBeginImageContext(CGSizeMake(80, 50));
    [string drawAtPoint:CGPointMake(10, 20)
               withFont:[UIFont systemFontOfSize:12]];
    UIImage *result = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    

    You can start with this

提交回复
热议问题