DownloadButton iOS 下载按钮开源项目

我要开发同款
匿名用户2015年06月25日
108阅读
所属分类Objective-C、iOS代码库、按钮(Button)
授权协议Apache 2.0

作品详情

DownloadButton是可自定义的AppStore风格的下载按钮。可自定义设计组件,用IB进行编辑。使用示例:

#pragma mark - PKDownloadButtonDelegate- (void)downloadButtonTapped:(PKDownloadButton *)downloadButton                 currentState:(PKDownloadButtonState)state {    switch (state) {        case kPKDownloadButtonState_StartDownload:            self.downloadButton.state = kPKDownloadButtonState_Pending;            [self.pendingSimulator startDownload];        break;        case kPKDownloadButtonState_Pending:            [self.pendingSimulator cancelDownload];            self.downloadButton.state = kPKDownloadButtonState_StartDownload;        break;            case kPKDownloadButtonState_Downloading:            [self.downloaderSimulator cancelDownload];            self.downloadButton.state = kPKDownloadButtonState_StartDownload;        break;        case kPKDownloadButtonState_Downloaded:            self.downloadButton.state = kPKDownloadButtonState_StartDownload;            self.imageView.hidden = YES;        break;        default:            NSAssert(NO, @"unsupported state");        break;    }}#pragma mark - DownloaderSimulatorDelegate- (void)simulator:(PKDownloaderSimulator *)simulator didUpdateProgress:(double)progress {    if (simulator == self.pendingSimulator) {        if (progress == 1.) {            self.downloadButton.state = kPKDownloadButtonState_Downloading;            [self.downloaderSimulator startDownload];        }    }    else if (simulator == self.downloaderSimulator) {        self.downloadButton.stopDownloadButton.progress = progress;        if (progress == 1) {            self.downloadButton.state = kPKDownloadButtonState_Downloaded;            self.imageView.hidden = NO;        }    }}

声明:本文仅代表作者观点,不代表本站立场。如果侵犯到您的合法权益,请联系我们删除侵权资源!如果遇到资源链接失效,请您通过评论或工单的方式通知管理员。未经允许,不得转载,本站所有资源文章禁止商业使用运营!
下载安装【程序员客栈】APP
实时对接需求、及时收发消息、丰富的开放项目需求、随时随地查看项目状态

评论