iOS 下載按鈕:DownloadButton
DownloadButton 是可自定義的 App Store 風格的下載按鈕。可自定義設計組件,用 IB 進行編輯。
使用示例:
#pragma mark - PKDownloadButtonDelegate
- (void)downloadButtonTapped:(PKDownloadButton *)downloadButton
switch (state) {currentState:(PKDownloadButtonState)state {
} } #pragma mark - DownloaderSimulatorDelegatecase 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;
- (void)simulator:(PKDownloaderSimulator *)simulator didUpdateProgress:(double)progress {
if (simulator == self.pendingSimulator) {
} else if (simulator == self.downloaderSimulator) {if (progress == 1.) { self.downloadButton.state = kPKDownloadButtonState_Downloading; [self.downloaderSimulator startDownload]; }
} }</pre>self.downloadButton.stopDownloadButton.progress = progress; if (progress == 1) { self.downloadButton.state = kPKDownloadButtonState_Downloaded; self.imageView.hidden = NO; }
本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!