This file contains 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
- (void)panningEndedWithTranslation:(CGPoint)translation velocity:(CGPoint)velocity | |
{ | |
self.panGestureRecognizer.enabled = NO; | |
CGFloat screenHeight = [[UIScreen mainScreen] bounds].size.height; | |
__weak ViewController *weakSelf = self; | |
switch (self.playerState) { | |
case PlayerStateThumbnail: | |
if (translation.y <= -screenHeight / 3 || velocity.y <= -100) |
This file contains 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
- (void)panningChangedWithTranslation:(CGPoint)translation | |
{ | |
if (self.playerViewAnimator.isRunning) | |
{ | |
return; | |
} | |
CGFloat translatedY = self.view.center.y + translation.y; | |
CGFloat progress; |
This file contains 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
typedef NS_ENUM(NSInteger, PlayerState) { | |
PlayerStateThumbnail, | |
PlayerStateFullscreen, | |
}; | |
@interface ViewController () | |
@property (weak, nonatomic) IBOutlet UIView *playerView; | |
@property (nonatomic) UIViewPropertyAnimator *playerViewAnimator; | |
@property (nonatomic) PlayerState playerState; |
This file contains 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
- (void)panningBegan | |
{ | |
if (self.playerViewAnimator.isRunning) | |
{ | |
return; | |
} | |
CGRect targetFrame; | |
switch (self.playerState) { |
This file contains 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
- (void)handlePan:(UIPanGestureRecognizer *)recognizer | |
{ | |
CGPoint translation = [recognizer translationInView:self.view.superview]; | |
if (recognizer.state == UIGestureRecognizerStateBegan) | |
{ | |
[self panningBegan]; | |
} | |
if (recognizer.state == UIGestureRecognizerStateEnded) | |
{ |
This file contains 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
- (void)viewDidLoad | |
{ | |
[super viewDidLoad]; | |
self.panGestureRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(handlePan:)]; | |
[self.view addGestureRecognizer:self.panGestureRecognizer]; | |
} |