feat:add Rotation for iOS

This commit is contained in:
pengfei.zhou
2019-11-27 10:19:25 +08:00
parent 2fbf4602e8
commit 3c04e7cde1
4 changed files with 27 additions and 6 deletions

View File

@@ -109,4 +109,11 @@ - (void)blendView:(DoricScrollView *)view forPropName:(NSString *)name propValue
- (void)blendSubNode:(NSDictionary *)subModel {
[self.childNode blend:subModel[@"props"]];
}
- (DoricViewNode *)subNodeWithViewId:(NSString *)viewId {
if ([viewId isEqualToString:self.childViewId]) {
return self.childNode;
}
return nil;
}
@end

View File

@@ -150,9 +150,11 @@ - (void)clearSubModel {
}
- (DoricViewNode *)subNodeWithViewId:(NSString *)viewId {
NSAssert(NO, @"Should override class:%@ ,method:%@.", NSStringFromClass([self class]),
NSStringFromSelector(_cmd));
return nil;
}
- (void)requestLayout {
[self.view setNeedsLayout];
}
@end
@end

View File

@@ -232,4 +232,14 @@ - (NSNumber *)getHeight {
return @(self.view.height);
}
- (void)setRotation:(NSNumber *)rotation {
self.view.transform = CGAffineTransformRotate(self.view.transform, M_PI * rotation.floatValue * 2);
}
- (NSNumber *)getRotation {
float radius = atan2f((float) self.view.transform.b, (float) self.view.transform.a);
float degree = (float) (radius / M_PI / 2);
return @(degree);
}
@end