Latest 0.1.3
Homepage https://github.com/daiquanxiang/DLVolumeButtons
License MIT
Platforms ios 8.0
Authors

CI Status
Version
License
Platform

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Demo效果

Requirements

Installation

DLVolumeButtons is available through CocoaPods. To install
it, simply add the following line to your Podfile:

pod 'DLVolumeButtons'

使用方法

需要强持有创建的对象

@property (nonatomic, strong) DLVolumeButtons *volumeButtons;

创建方法

- (void)setupVolumeButtons
{
    if (!self.volumeButtons) {

        __weak typeof(self) weakSelf = self;
        self.volumeButtons = [DLVolumeButtons volumeButtonHandlerWithUpBlock:^{
            NSLog(@"点击了 上音量键");
            [weakSelf showAlertWithText:@"点击了 上音量键"];
        } downBlock:^{
            NSLog(@"点击了 下音量键");
            [weakSelf showAlertWithText:@"点击了 下音量键"];
        }];

        if ([self.volumeButtons respondsToSelector:@selector(changeVolumeSuperView:)]) {
            [self.volumeButtons changeVolumeSuperView:self.view];
        }
    }
}

灵活开关 是否替换系统音量view

- (IBAction)valueChanged:(UISegmentedControl *)sender {
    if (sender.selectedSegmentIndex) {
        // 开
        [self.volumeButtons startHandler:YES];
    } else {
        // 关
        [self.volumeButtons stopHandler];
    }
}

注意

建议最好将当前可视窗口传给 DLVolumeButton,代码里面创建了一个 MPVolumeView 音量view,默认放在最前面的 window里,当你替换了音量键事件后,没有将新创建 音量view 放在当前 self.view上,有可能替换了事件但是还是会出现系统改音量的窗口。

[self.volumeButtons changeVolumeSuperView:self.view];

Author

daiquanxiang, [email protected]

License

DLVolumeButtons is available under the MIT license. See the LICENSE file for more info.

Latest podspec

{
    "name": "DLVolumeButtons",
    "version": "0.1.3",
    "summary": "u6355u6349u97f3u91cfu952eu4e8bu4ef6uff0cu4e0du663eu793au7cfbu7edfu97f3u91cfu7a97u53e3u3002u6355u6349u97f3u91cfu4e8bu4ef6uff0cu53efu4ee5u63a7u5236u7ee7u7eedu4feeu6539u97f3u91cfuff0cu4e5fu53efu4ee5u4e0du4feeu6539u97f3u91cfu3002",
    "description": "TODO: Add long description of the pod here.",
    "homepage": "https://github.com/daiquanxiang/DLVolumeButtons",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "daiquanxiang": "[email protected]"
    },
    "source": {
        "git": "https://github.com/daiquanxiang/DLVolumeButtons.git",
        "tag": "0.1.3"
    },
    "platforms": {
        "ios": "8.0"
    },
    "source_files": "DLVolumeButtons/Classes/**/*.{h,m}"
}

Pin It on Pinterest

Share This