Last active
September 11, 2015 16:58
-
-
Save percysnoodle/8e770bd127702ea08d64 to your computer and use it in GitHub Desktop.
First attempt at a tvOS motion effect suitable for focusable objects
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// SGBtvOSMotionEffect.m | |
// | |
// Created by Simon Booth on 11/09/2015. | |
// Copyright © 2015 agbooth.com. All rights reserved. | |
// | |
#import "SGBtvOSMotionEffect.h" | |
@implementation SGBtvOSMotionEffect | |
- (nullable NSDictionary<NSString *, id> *)keyPathsAndRelativeValuesForViewerOffset:(UIOffset)viewerOffset | |
{ | |
CATransform3D transform = CATransform3DIdentity; | |
transform.m34 = 0.001; | |
transform = CATransform3DRotate(transform, viewerOffset.horizontal * -0.1, 0, 1, 0); | |
transform = CATransform3DRotate(transform, viewerOffset.vertical * 0.1, 1, 0, 0); | |
return @{ @"layer.transform" : [NSValue valueWithCATransform3D:transform] }; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment