Skip to content

Instantly share code, notes, and snippets.

@zapsleep
Created December 13, 2012 07:57
Show Gist options
  • Save zapsleep/4274864 to your computer and use it in GitHub Desktop.
Save zapsleep/4274864 to your computer and use it in GitHub Desktop.
Observe AirPlay button's alpha
//setting the observer
-(void)observeAirPlayFromView:(MPVolumeView *)voluemView {
for (UIButton *button in volumeView.subviews) {
if([button isKindOfClass:[UIButton class]]) {
[button addObserver:self
forKeyPath:@"alpha"
options:NSKeyValueObservingOptionNew
context:nil];
}
}
}
//observing
- (void)observeValueForKeyPath:(NSString *)keyPath
ofObject:(id)object
change:(NSDictionary *)change
context:(void *)context {
if ([object isKindOfClass:[UIButton class]] &&
[[change valueForKey:NSKeyValueChangeNewKey] intValue] == 1) {
//do something
}
}
@zSoNz
Copy link

zSoNz commented Aug 15, 2018

If your read this at now, this solution is not relevant. Read documentation link below.
https://developer.apple.com/documentation/foundation/nsnotification/name/1620065-mpvolumeviewwirelessroutesavaila

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment