A UIControl
with a play/pause icon that nicely morphs between the two.
You can choose from two morphing styles: Split, and Split & Rotate.
If using CocoaPods, the quickest way to try it out is to type this on the command line:
$ pod try RSPlayPauseButton
To add it to your app, copy the class RSPlayPauseButton.h/.m
into your Xcode project or add via CocoaPods by adding this to your Podfile:
pod 'RSPlayPauseButton', '~> 1.0'
In your code, #import "RSPlayPauseButton.h"
, create the control, and setup an action to toggle it:
// ... e.g. in `-viewDidLoad:` ...
RSPlayPauseButton *playPauseButton = [[RSPlayPauseButton alloc] init];
[playPauseButton addTarget:self action:@selector(playPauseButtonDidPress:) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:playPauseButton];
}
- (void)playPauseButtonDidPress:(RSPlayPauseButton *)playPauseButton {
[playPauseButton setPaused:!playPauseButton.isPaused animated:YES];
}
Since I release RSPlayPauseButton as free and unencumbered software into the public domain you can do with it whatever you want including using it in any app on the App Store. I originally released this code in early 2014 as a gist and was happy to see Google (or should one say Alphabet now?) adding the Split style in mid-2015 to the YouTube.com player.
Feel free to reach out to @RaphaelSchaad and say hi.