gbkui-button-progress-view

Inspired by Apple’s download progress buttons in the app store

Github星跟蹤圖

GBKUIButtonProgressView

Inspired by Apple’s download progress buttons in the app store

Created by @pklada and @miketsprague

Checkout the blog post.

gif

Installation

Cocoapods

pod 'GBKUIButtonProgressView', git: 'https://github.com/Guidebook/gbkui-button-progress-view'

Manually add to your project

Just add the files in GBKUIButtonProgressView/ to your project

Usage

  • Create the button as a custom view in your xib, or create it programatically
  • Make sure that you don't have a constraint for its width (it shrinks)--you might need to set the Intrinsic Content Size to "Placeholder" in your xib to avoid errors

intrinsic content size

self.downloadButton.initialTitle = @"Download";
self.downloadButton.completeTitle = @"Open";

// Add a target (like a regular button)
[self.downloadButton addTarget:self action:@selector(downloadButtonPressed:) forControlEvents:UIControlEventTouchUpInside];

-(void)downloadButtonPressed:(id)sender {
    // Update the button's state based on your downloading item's state
    if(!self.isDownloading && !self.isDownloaded) {
        [self.downloadButton startProgressing];
        [self downloadItem];
    } else if(self.isDownloaded) {
        [self openItem];
    } else {
        [self cancelDownloadingItem];
        [self.downloadButton setProgress:0 animated:YES withCompletion:^{
            [self.downloadButton reset];
        }];
    }
}

-(void)downloadProgressed:(CGFloat)progress {
  // Update the download button's progress when you get a progress update from your item
  [self.downloadButton setProgress:progress animated:YES];
}

To change the tint color, simply:

self.downloadButton.tintColor = [UIColor redColor];

See the example for more info.

Todos

  • Polish the API a bit
  • Allow it to be IBDesignable
  • Inherit from UIControl instead of UIView

主要指標

概覽
名稱與所有者Guidebook/gbkui-button-progress-view
主編程語言Objective-C
編程語言Objective-C (語言數: 2)
平台
許可證MIT License
所有者活动
創建於2015-12-15 19:52:58
推送於2016-05-26 22:44:40
最后一次提交2016-05-26 15:44:20
發布數1
最新版本名稱0.1.2 (發布於 )
第一版名稱0.1.2 (發布於 )
用户参与
星數540
關注者數27
派生數41
提交數30
已啟用問題?
問題數7
打開的問題數4
拉請求數3
打開的拉請求數1
關閉的拉請求數1
项目设置
已啟用Wiki?
已存檔?
是復刻?
已鎖定?
是鏡像?
是私有?