Extend OpenVulkanoOrientationLockableViewController
This commit is contained in:
@@ -29,6 +29,17 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
-(CGFloat)getOrientation {
|
||||||
|
if (_rotationLockedView == nil) return 0;
|
||||||
|
return [[_rotationLockedView.layer valueForKeyPath:@"transform.rotation.z"] floatValue];
|
||||||
|
}
|
||||||
|
|
||||||
|
-(void)setOrientation:(CGFloat)angle {
|
||||||
|
if (_rotationLockedView != nil) {
|
||||||
|
[_rotationLockedView.layer setValue:@(angle) forKeyPath:@"transform.rotation.z"];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
-(void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator {
|
-(void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator {
|
||||||
[super viewWillTransitionToSize:size withTransitionCoordinator:coordinator];
|
[super viewWillTransitionToSize:size withTransitionCoordinator:coordinator];
|
||||||
|
|
||||||
@@ -38,10 +49,10 @@
|
|||||||
CGAffineTransform deltaTransform = coordinator.targetTransform;
|
CGAffineTransform deltaTransform = coordinator.targetTransform;
|
||||||
CGFloat deltaAngle = atan2f(deltaTransform.b, deltaTransform.a);
|
CGFloat deltaAngle = atan2f(deltaTransform.b, deltaTransform.a);
|
||||||
|
|
||||||
CGFloat currentRotation = [[_rotationLockedView.layer valueForKeyPath:@"transform.rotation.z"] floatValue];
|
CGFloat currentRotation = [self getOrientation];
|
||||||
// Adding a small value to the rotation angle forces the animation to occur in a the desired direction, preventing an issue where the view would appear to rotate 2PI radians during a rotation from LandscapeRight -> LandscapeLeft.
|
// Adding a small value to the rotation angle forces the animation to occur in a the desired direction, preventing an issue where the view would appear to rotate 2PI radians during a rotation from LandscapeRight -> LandscapeLeft.
|
||||||
currentRotation += -1 * deltaAngle + 0.0001;
|
currentRotation += -1 * deltaAngle + 0.0001;
|
||||||
[_rotationLockedView.layer setValue:@(currentRotation) forKeyPath:@"transform.rotation.z"];
|
[self setOrientation:currentRotation];
|
||||||
|
|
||||||
} completion:^(id <UIViewControllerTransitionCoordinatorContext> context) {
|
} completion:^(id <UIViewControllerTransitionCoordinatorContext> context) {
|
||||||
// Integralize the transform to undo the extra 0.0001 added to the rotation angle.
|
// Integralize the transform to undo the extra 0.0001 added to the rotation angle.
|
||||||
|
|||||||
@@ -16,6 +16,8 @@
|
|||||||
|
|
||||||
@property (nonatomic, strong) OpenVulkanoView* openVulkanoView;
|
@property (nonatomic, strong) OpenVulkanoView* openVulkanoView;
|
||||||
|
|
||||||
|
-(id)init;
|
||||||
|
|
||||||
-(void*) makeGraphicsApp;
|
-(void*) makeGraphicsApp;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
@@ -24,4 +26,12 @@
|
|||||||
|
|
||||||
@property (nonatomic, strong) UIView* rotationLockedView;
|
@property (nonatomic, strong) UIView* rotationLockedView;
|
||||||
|
|
||||||
|
//@property CGFloat baseRotation;
|
||||||
|
|
||||||
|
-(id)init;
|
||||||
|
|
||||||
|
-(CGFloat)getOrientation;
|
||||||
|
|
||||||
|
-(void)setOrientation:(CGFloat)angle;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|||||||
Reference in New Issue
Block a user