ios screenshot refactoring
This commit is contained in:
parent
a6f994deae
commit
2ea7288186
13
README.md
13
README.md
@ -1824,13 +1824,16 @@ console.log('executablePath =', ObjC.classes.NSBundle.mainBundle().executablePat
|
|||||||
```js
|
```js
|
||||||
function screenshot() {
|
function screenshot() {
|
||||||
ObjC.schedule(ObjC.mainQueue, function() {
|
ObjC.schedule(ObjC.mainQueue, function() {
|
||||||
|
var getNativeFunction = function (ex, retVal, args) {
|
||||||
|
return new NativeFunction(Module.findExportByName('UIKit', ex), retVal, args);
|
||||||
|
};
|
||||||
var api = {
|
var api = {
|
||||||
UIWindow: ObjC.classes.UIWindow,
|
UIWindow: ObjC.classes.UIWindow,
|
||||||
NSThread: ObjC.classes.NSThread,
|
UIGraphicsBeginImageContextWithOptions: getNativeFunction('UIGraphicsBeginImageContextWithOptions', 'void', [['double', 'double'], 'bool', 'double']),
|
||||||
UIGraphicsBeginImageContextWithOptions: new NativeFunction(Module.findExportByName('UIKit', 'UIGraphicsBeginImageContextWithOptions'), 'void', [['double', 'double'], 'bool', 'double']),
|
UIGraphicsBeginImageContextWithOptions: getNativeFunction('UIGraphicsBeginImageContextWithOptions', 'void', [['double', 'double'], 'bool', 'double']),
|
||||||
UIGraphicsEndImageContext: new NativeFunction(Module.findExportByName('UIKit', 'UIGraphicsEndImageContext'), 'void', []),
|
UIGraphicsEndImageContext: getNativeFunction('UIGraphicsEndImageContext', 'void', []),
|
||||||
UIGraphicsGetImageFromCurrentImageContext: new NativeFunction(Module.findExportByName('UIKit', 'UIGraphicsGetImageFromCurrentImageContext'), 'pointer', []),
|
UIGraphicsGetImageFromCurrentImageContext: getNativeFunction('UIGraphicsGetImageFromCurrentImageContext', 'pointer', []),
|
||||||
UIImagePNGRepresentation: new NativeFunction(Module.findExportByName('UIKit', 'UIImagePNGRepresentation'), 'pointer', ['pointer'])
|
UIImagePNGRepresentation: getNativeFunction('UIImagePNGRepresentation', 'pointer', ['pointer'])
|
||||||
};
|
};
|
||||||
var view = api.UIWindow.keyWindow();
|
var view = api.UIWindow.keyWindow();
|
||||||
var bounds = view.bounds();
|
var bounds = view.bounds();
|
||||||
|
Loading…
Reference in New Issue
Block a user