Skip to content

Instantly share code, notes, and snippets.

@0xced
Created December 17, 2014 09:54
Show Gist options
  • Star 11 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 0xced/df51b8a3e8584df3ad72 to your computer and use it in GitHub Desktop.
Save 0xced/df51b8a3e8584df3ad72 to your computer and use it in GitHub Desktop.
Access the "Done" button of a MPMoviePlayerController
#import <MediaPlayer/MediaPlayer.h>
/**
* Example usage:
* UIButton *doneButton = MoviePlayerControllerDoneButton(moviePlayerViewController.moviePlayer);
* [doneButton setTitle:@"✖" forState:UIControlStateNormal];
* doneButton.titleLabel.font = [UIFont systemFontOfSize:30];
*/
extern UIButton * MoviePlayerControllerDoneButton(MPMoviePlayerController *moviePlayerController);
#import "MoviePlayerControllerDoneButton.h"
static UIButton * DoneButton(UIView *view)
{
if ([view isKindOfClass:[UIButton class]])
{
UIButton *button = (UIButton *)view;
NSString *buttonTitle = [button titleForState:UIControlStateNormal];
NSBundle *mediaPlayerBundle = [NSBundle bundleForClass:[MPMoviePlayerViewController class]];
NSString *doneTitle = [mediaPlayerBundle localizedStringForKey:@"DONE" value:@"" table:@"MediaPlayer"];
if ([buttonTitle isEqualToString:doneTitle])
return button;
}
UIButton *doneButton = nil;
for (UIView *subview in view.subviews)
{
doneButton = DoneButton(subview);
if (doneButton)
break;
}
return doneButton;
}
UIButton * MoviePlayerControllerDoneButton(MPMoviePlayerController *moviePlayerController)
{
return DoneButton(moviePlayerController.view);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment