EGSpinner 1.0.1

EGSpinner 1.0.1

Evgeny Glukhov 维护。



EGSpinner 1.0.1

  • EGApplications

EGSpinner

简单的 iOS 加载指示器和按钮。

安装

您可以使用 CocoaPods 安装 EGSpinner。只需在 Podfile 中写入以下内容

pod ‘EGSpinner’

使用方法

加载指示器的主体元素是 EGCleverProgress 类,您可以通过如下方式初始化和自定义它

- (void) viewDidLoad
{
[super viewDidLoad];

// example

// initialization
EGCleverProgress* clever = [[EGCleverProgress alloc] init];
clever.cleverBackgroundColor = [UIColor greenColor];

// custom delegate
clever.delegate = self;

// customization of button on clever progress
clever.closeButton.hidden = NO;
[clever.closeButton setImage:[UIImage imageNamed:@"[email protected]"] forState:UIControlStateNormal];

// alertLabel & cleverView customization
clever.cleverView.backgroundColor = UIColor.redColor;
clever.alertLabel.textColor = UIColor.magentaColor;

[self.view addSubview:clever];

}

EGCleverProgress 头文件让您控制加载过程的主要操作,例如,在加载过程通知完成时,以及处理按钮动作的代理方法。

@class EGCleverProgress;

static NSString* loadingNotification = @"EGCleverProgressLoadingNotification";
static NSString* hasBeenDownloadedNotification = @"EGCleverProgressHasBeenDownloadedNotification";

@protocol EGCleverProgressDelegate <NSObject>

@optional

- (void) didSelectCleverButton:(EGCleverProgress*) clever;
- (void) cleverProgress:(EGCleverProgress*) clever didSelectCloseButton:(UIButton*) closeButton;

@end

@interface EGCleverProgress : UIView

// initialization
- (instancetype)init;

// system
@property (strong, nonatomic) UIView* cleverView;
@property (strong, nonatomic) UILabel* alertLabel;
@property (strong, nonatomic) UIButton* closeButton;
@property (strong, nonatomic) EGSpinnerLayer* spinner;

// for user
@property (strong, nonatomic) UIColor* cleverBackgroundColor;
@property (weak, nonatomic) id <EGCleverProgressDelegate> delegate;

@end

您也可以分别初始化和使用加载指示器

@interface EGSpinnerLayer : CAShapeLayer

- (instancetype) initWithFrame:(CGRect)frame;
- (void) startSpin;
- (void) stopSpin;

@end

加载过程示例

// notify Clever Progress to start the spinner at the beginning of loading process.
[[NSNotificationCenter defaultCenter] postNotificationName:loadingNotification object:nil];

// Here after 3 seconds spinner will stop and alertLabel will update its status to "Data has been downloaded"
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[[NSNotificationCenter defaultCenter] postNotificationName:hasBeenDownloadedNotification object:@{@"status":@"Data has been downloaded"}];
clever.closeButton.hidden = YES;
});

MIT 许可证 (MIT)

版权所有 © 2018 EGApplications

以下是对本文档和关联文档文件(“软件”)的副本进行处理的许可,免费分发的不得限制,包括但不限于使用的权利、复制的权利、修改的权利、合并的权利、发布的权利、分发的权利、再许可的权利和/或销售副本的权利,并允许向软件提供者提供 software 的任何人进行如此操作,但需遵守以下条件

上述版权声明和本许可声明应包含在软件的副本或实质性部分中。

软件按“原样”提供,不提供任何形式的保证,无论是明示的、隐示的或法律强制规定的,包括但不限于适销性保证、针对特定目的的适用性保证和非侵权性保证。在任何情况下,作者或版权所有者均不对任何索赔、损害或其他责任负责,无论是否因合同违约、侵权或其他原因而产生,无论是否与软件或其使用或其他操作有关。