DownloadButton 介绍
DownloadButton 是可自定义的 App Store 风格的下载按钮。可自定义设计组件,用 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; } } }
DownloadButton 官网
https://github.com/PavelKatunin/DownloadButton
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。