GUIRoundProgressButton 0.0.2

GUIRoundProgressButton 0.0.2

测试已测试
语言语言 Obj-CObjective C
许可证 MIT
发布最后发布2015年5月

Guilherme Araújo 维护。



  • 作者:
  • Guilherme Araújo

Animated gif

安装

CocoaPods (推荐)
将以下行添加到您的 Podfile
pod 'GUIRoundProgressButton', '~> 0.0.2
然后,在您的视图控制器中添加 #import <GUIRoundProgressButton.h>

手动
将文件夹 Classes 复制到您的项目中,然后将 #import "GUIRoundProgressButton.h" 添加到您的视图控制器。

使用方法

要使用它,您应创建一个扩展 GUIRoundProgressButton 的视图控制器。这可以通过两种方式完成

使用界面构建器

  • 将一个 UIView 对象添加到您的视图中
  • 将其类更改为 GUIRoundProgressButton
  • 在您的视图或视图控制器源文件中创建一个 IBOutlet

以编程方式添加按钮

  • 创建实例:GUIRoundProgressButton *button = [GUIRoundProgressButton buttonWithCenter:<#CGPoint#> radius:<#CGFloat#>];
  • 将其添加为子视图:[self.view addSubview:button];

自定义

以下是您可以使用的方法来自定义按钮的外观和感觉。其中,“touch”方法与按钮被用户按下时的颜色相关。

内容填充

- (CGFloat)setContentPadding;

边框

- (CGFloat)setBorderWidth;
- (UIColor *)setBorderColor;
- (UIColor *)setTouchBorderColor;

颜色

- (UIColor *)setForegroundColor;
- (UIColor *)setTouchForegroundColor;

进度指示器

- (UIColor *)setProgressIndicatorColor;

图片

- (void)setImage:(UIImage *)image;

文本

- (void)setText:(NSString *)text;
- (void)setAttributedText:(NSAttributedString *)text;

注意:图像或文本中必有其一可见。如果两者都设置,则最后设置的会被使用。

动作

这是按钮被轻触后的动作。

- (void)setActionBlock:^(GUIRoundProgressButton *weakButton);
示例
[button setActionBlock:^(GUIRoundProgressButton *weakButton) {
  // Perform your tasks here

  // At the end, call finish using the weak reference to prevent memory leaks
  [weakButton finish];
}];

注意: 不要忘记在完成任务后调用 finish 方法。使用按钮的弱引用以防止内存泄露。