Skip to content

Simply capture screenshots and create screen recordings from code in iOS.

License

Notifications You must be signed in to change notification settings

uxmstudio/UIScreenCapture

Repository files navigation

UIScreenCapture

Version License Platform

Simply capture screenshots and create screen recordings from code.

Installation

CocoaPods

UIScreenCapture is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod "UIScreenCapture", '~> 0.0.5'

Usage

Capture Screen Recording

// Initialize the screen capture
UIScreenCapture *screenCapture = [UIScreenCapture new];
screenCapture.height = 480.0;
screenCapture.width = 640.0;
screenCapture.frameRate = 15.0;
screenCapture.completionBlock = ^(NSURL *fileURL) {
    NSLog(@"Finished! Video located at: %@", fileURL);
};

// Begin screen capture
[screenCapture startRecording];

dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, 10 * NSEC_PER_SEC);
dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
    
    // Stop screen capture after ten seconds
    [screenCapture stopRecording];
});

Take Screenshot

[UIScreenCapture takeSnapshot];

Interface

// Variables
@property (nonatomic) CGFloat height;
@property (nonatomic) CGFloat width;
@property (nonatomic) CGFloat frameRate;
@property (nonatomic, strong) UIView *view; // If you wish to capture something other than the whole screen
@property (nonatomic, copy) UIScreenCaptureCompletion completionBlock;

// Record screen
- (void)startRecording;
- (void)stopRecording;

// Create video from images
- (void)createVideoFromImageURLs:(NSArray *)urls withCompletion:(UIScreenCaptureCompletion)completion;
- (void)createVideoFromImages:(NSArray *)images withCompletion:(UIScreenCaptureCompletion)completion;

// Snapshots
+ (UIImage *)takeSnapshot;
+ (UIImage *)takeSnapshotWithSize:(CGSize)size;
+ (UIImage *)takeSnapshotWithSize:(CGSize)size view:(UIView *)view;
+ (NSData *)takeSnapshotGetJPEG;
+ (NSData *)takeSnapshotGetJPEG:(CGFloat)quality;
+ (NSData *)takeSnapshotGetJPEG:(CGFloat)quality size:(CGSize)size;

Author

Chris Anderson:

License

UIScreenCapture is available under the MIT license. See the LICENSE file for more info.

About

Simply capture screenshots and create screen recordings from code in iOS.

Resources

License

Stars

Watchers

Forks

Packages

No packages published