How to create an image from UILabel?

前端 未结 6 1818
情深已故
情深已故 2020-12-01 07:55

I\'m currently developing a simple photoshop like application on iphone. When I want to flatten my layers, the labels are at the good position but with a bad font size. Here

6条回答
  •  囚心锁ツ
    2020-12-01 08:17

    you need to render the label in a context

    replace

    [label drawTextInRect:label.frame];
    

    with

    [label.layer renderInContext:UIGraphicsGetCurrentContext()];
    

    and you will need to create one image per label, so move the for loop to outside the begin and end context calls

提交回复
热议问题