Skip to content

Instantly share code, notes, and snippets.

@percysnoodle
Last active September 11, 2015 16:58
Show Gist options
  • Save percysnoodle/8e770bd127702ea08d64 to your computer and use it in GitHub Desktop.
Save percysnoodle/8e770bd127702ea08d64 to your computer and use it in GitHub Desktop.
First attempt at a tvOS motion effect suitable for focusable objects
//
// 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