How to take a screenshot using code on iOS?

前端 未结 2 1231
北恋
北恋 2021-02-03 16:23

How to take a screenshot programmatically?

2条回答
  •  闹比i
    闹比i (楼主)
    2021-02-03 17:00

    Have a look at this answer.It also takes care of retina display.

    Actually to explain the process,

    • Choose a image context size (probably the layer size for which you need screen shot)
    • Render the layer which you want to take screenshot in the created context
    • Obtain the image from the context and you are done!

提交回复
热议问题