davidisaaclee / ViewRecorder

A library to record a UIView to video.
2 stars 0 forks source link

how to use to record uiview #1

Closed ashish5016 closed 3 years ago

ashish5016 commented 3 years ago

can't understand how to use function...

davidisaaclee commented 3 years ago

sorry I didn't see this – this is pretty old code, so I don't remember (and it may not work in latest iOS / Swift). but there seems to be a full example in the repo here: https://github.com/davidisaaclee/ViewRecorder/blob/master/ViewRecorder/ViewController.swift

the important lines seem to be:

  1. create a RecordingContextImpl, passing the UIView you want to record:

https://github.com/davidisaaclee/ViewRecorder/blob/c2422158b93c6615959f8f1d7df4d76a14d05746/ViewRecorder/ViewController.swift#L22

  1. Call resumeRecording or pauseRecording to record:

https://github.com/davidisaaclee/ViewRecorder/blob/c2422158b93c6615959f8f1d7df4d76a14d05746/ViewRecorder/ViewController.swift#L41-L47

  1. Export the recording to a file using recorder.exportRecording():

https://github.com/davidisaaclee/ViewRecorder/blob/c2422158b93c6615959f8f1d7df4d76a14d05746/ViewRecorder/ViewController.swift#L50-L54

sorry if this is more confusing than it should be – I didn't think about other people using this library, but you are free to do so.

I know that Apple has made ReplayKit more powerful since I wrote this code – I would look at that and related first-party code to see if there is a better facility for what you are trying to do. https://developer.apple.com/documentation/replaykit

davidisaaclee commented 3 years ago

feel free to reopen if this is still an issue