作为 Objective-C Hackathon 的一部分,我想尝试创建一个用于显示进度的按钮,就像新 iOS 7 版本的 App Store 中的进度按钮一样。这个进度按钮是将 UIButton 和 UIProgressView 结合起来,再加上其他一些东西的产物。也许它会有用,也许只是好玩。由你决定。
- (void)viewDidLoad
{
[super viewDidLoad];
self.progressButton.delegate = self;
self.progressButton.tintColor = [UIColor blueColor];
self.progressButton.startButtonImage = [UIImage imageNamed:@"download-image"];
self.progressButton.endButtonImage = [UIImage imageNamed:@"action-image"];
}
- (void)progressButtonStartButtonTapped:(JNJProgressButton *)button
{
// Begin doing the download action or whatever asyncronous thing you need to do. Then start updating the progress progerty on the button.
}
- (void)progressButtonEndButtonTapped:(JNJProgressButton *)button
{
// The button has reached the end of the progress and the user can now do whatever the action needed.
}
- (void)progressButtonDidCancelProgress:(JNJProgressButton *)button
{
// The user has canceled the progress
}
JNJProgressButton
可在 MIT 许可下获得,请参阅 LICENSE 文件以获取更多信息。