feat:set rotation as view's prop

This commit is contained in:
pengfei.zhou
2019-11-29 15:16:15 +08:00
parent 4e596642f2
commit 3a89571f42
7 changed files with 42 additions and 13 deletions

View File

@@ -123,6 +123,8 @@ - (void)blendView:(UIView *)view forPropName:(NSString *)name propValue:(id)prop
view.y = [(NSNumber *) prop floatValue];
} else if ([name isEqualToString:@"bgColor"]) {
view.backgroundColor = DoricColor(prop);
} else if ([name isEqualToString:@"rotation"]) {
[self setRotation:prop];
} else if ([name isEqualToString:@"layoutConfig"]) {
if (self.superNode && [prop isKindOfClass:[NSDictionary class]]) {
[self.superNode blendSubNode:self layoutConfig:prop];
@@ -238,13 +240,13 @@ - (void)setRotation:(NSNumber *)rotation {
if (rotation.floatValue == 0) {
self.view.transform = CGAffineTransformIdentity;
} else {
self.view.transform = CGAffineTransformMakeRotation(M_PI * rotation.floatValue * 2);
self.view.transform = CGAffineTransformMakeRotation(M_PI * rotation.floatValue);
}
}
- (NSNumber *)getRotation {
float radius = atan2f((float) self.view.transform.b, (float) self.view.transform.a);
float degree = (float) (radius / M_PI / 2);
float degree = (float) (radius / M_PI);
return @(degree);
}