Black rectangle when screenshoting the view
See original GitHub issueHi @brentvatne ,
I’m currently attempting to recreate this example made with gl-react but with gl-react-native.
Unfortunately I’m getting a black screen. The way my code works is by screenshot-ing the UIView like this:
UIGraphicsBeginImageContextWithOptions(view.frame.size, NO, RCTScreenScale());
[view drawViewHierarchyInRect:view.frame afterScreenUpdates:YES];
UIImage *snapshot = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
// (I also tried with an equivalent code that uses `view.layer renderInContext`)
It works with usual content (like <View/>
<Text/>
<Image/>
) but not with this library <Video/>
. Do you know why? Is there any way to fix that?
Screenshot-ing an AVPlayer seems to be possible like this: http://stackoverflow.com/a/12415177/343892
But I’m trying to find a generic solution that works with any UIView so I don’t have to explicitly depends on RCTVideo to “cast” the UIView.
EDIT: ultimately I will have to dig into this, if I want to improve perfs of this. I’ve seen this stuff too: https://developer.apple.com/library/ios/samplecode/AVBasicVideoOutput/Introduction/Intro.html#//apple_ref/doc/uid/DTS40013109 . I wish there where a “generic” way to handle this. (can we do duck typing in ObjC? 😄 )
Thanks
EDIT: related http://stackoverflow.com/questions/23286252/screenshot-for-avplayer-and-video
Issue Analytics
- State:
- Created 8 years ago
- Reactions:5
- Comments:6 (2 by maintainers)
Top GitHub Comments
plus
Infinity
👍as the (now) author of
react-native-view-shot
it would be great if we can find a generic solution to this problem (not saying it’s possible, but would be ideal). We have apparently found a generic solution that should (not sure) work for Android as commented in https://github.com/gre/react-native-view-shot/issues/36 (in Android, some views like opengl backed view provided via react-native-map or some other view like a webview tends to render transparent black/white instead of the actual content – same happens in iOS, but not sure about if there is a generic solution).