0

I'm wondering is it possible to create a custom airplay button and add it to a toolbar? i.e. I would like to create button that open the same popover that original AirPlay button, to share all the screen. I saw that it is possible to do with MPMoviePlayerController or WebView, but in that way I send on air a video or audio, but non all the screen...

Thans

Max
  • 319
  • 2
  • 9

1 Answers1

1

In iOS 5 there were some hoops to jump through. In iOS 6, it's much easier. Add a MPVolumeView and use setRouteButtonImage:forState: to change the icon:

airplayView = [[MPVolumeView alloc] initWithFrame:airplayContainer.bounds];
airplayView.showsVolumeSlider = NO;
[airplayView setRouteButtonImage:[UIImage imageNamed:@"airplay"] forState:UIControlStateNormal];
[airplayView setRouteButtonImage:[UIImage imageNamed:@"airplay-highlighted"] forState:UIControlStateHighlighted];
[airplayView setRouteButtonImage:[UIImage imageNamed:@"airplay-selected"] forState:UIControlStateSelected];
[airplayContainer addSubview:airplayView]; // or add it to your toolbar or wherever

airplayContainer is just a plain UIView I added in Interface Builder to get the layout I wanted.

Community
  • 1
  • 1
swilliams
  • 48,060
  • 27
  • 100
  • 130