Quang Dam
Quang Dam

Reputation: 325

How to expand the MPVolumeView route button area?

I am currently using MPVolume to stream audio from my app to Apple TV. MPVolume has route button and I want to expand the touching area of this.

UIButton *button;
for (id object in self.volumeView.subviews) {
    if ([object isKindOfClass:[UIButton class]]) {
        button = object;
    }
}

I use snippet code above to catch up this button and set the new frame for it but it does not work.

enter image description here

Upvotes: 1

Views: 262

Answers (1)

Cuong Nguyen
Cuong Nguyen

Reputation: 222

You can subclass MPVolumeView, override layoutSubviews method, on this method, find the Button and resize it.

- (void)layoutSubviews {
    [super layoutSubviews];

    for (UIView *view in self.subviews) {
        if (view.class == NSClassFromString(@"MPButton")){
        //Do something here
        }
    }
}

Upvotes: 1

Related Questions