forked from bang590/JSPatch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
JPUIGeometry.m
46 lines (36 loc) · 1.23 KB
/
JPUIGeometry.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
//
// JPUIGeometry.m
// JSPatchDemo
//
// Created by Albert438 on 15/7/6.
// Copyright (c) 2015年 bang. All rights reserved.
//
#import "JPUIGeometry.h"
#import "JPCGGeometry.h"
#import <UIKit/UIKit.h>
@implementation JPUIGeometry
+ (void)main:(JSContext *)context
{
[JPEngine defineStruct:@{@"name": @"UIEdgeInsets",
@"types": @"FFFF",
@"keys": @[@"top", @"left", @"bottom", @"right"]
}];
[JPEngine defineStruct:@{@"name": @"UIOffset",
@"types": @"FF",
@"keys": @[@"horizontal", @"vertical"]
}];
context[@"CGRectFromString"] = ^CGRect(NSString *string) {
return CGRectFromString(string);
};
context[@"CGSizeFromString"] = ^CGSize(NSString *string) {
return CGSizeFromString(string);
};
context[@"CGPointFromString"] = ^CGPoint(NSString *string) {
return CGPointFromString(string);
};
context[@"CGVectorFromString"] = ^NSDictionary *(NSString *string) {
CGVector vector = CGVectorFromString(string);
return [JPCGGeometry vectorDictOfStruct:&vector];
};
}
@end