Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
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)
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