Print a UIView, but NOT by rendering as a bitmap image

前端 未结 1 1250
清歌不尽
清歌不尽 2020-12-18 17:07

Say you have a simple UIView with only text (ie, UILabel) and maybe some black lines.

\"enter

相关标签:
1条回答
  • 2020-12-18 17:57

    As Apple Doc states, viewPrintFormatter attribute of UIView is defined in a UIView category but it's available only for instances of type: UITextView, MKMapView and UIWebView.

    So you can either:

    • print UIView using it's layer attribute and flattening all its content
    • initialize a UIWebView with the content to print and giving its viewPrintFormatter attribute to a pageRenderer and render each page
    0 讨论(0)
提交回复
热议问题