将 CCActivityIndicatorView 文件夹中的 .h 和 .m 文件添加到您的项目中。
将 ImageIO.framework
添加到您的目标中。
#import "CCActivityIndicatorView.h"
self.myactivityIndicatorView = [CCActivityIndicatorView new];
// Show with the default type
// The 1st capture
[self.myactivityIndicatorView show];
或者您可以指定要显示的类型
self.myactivityIndicatorView = [CCActivityIndicatorView new];
// CCActivityIndicatorView with type CCIndicatorTypeScalingDots
// The 1st capture
[self.myactivityIndicatorView showWithType:CCIndicatorTypeScalingDots];
// CCActivityIndicatorView with type CCIndicatorTypeLeadingDots
// The 2nd capture
[self.myactivityIndicatorView showWithType:CCIndicatorTypeLeadingDots];
// CCActivityIndicatorView with type CCIndicatorTypeCircle
// The 3rd capture
[self.myactivityIndicatorView showWithType:CCIndicatorTypeCircle];
// CCActivityIndicatorView with type CCIndicatorTypeArc
// The 4th capture
[self.myactivityIndicatorView showWithType:CCIndicatorTypeArc];
或者您甚至可以使用自己的 GIF 文件
self.myactivityIndicatorView = [CCActivityIndicatorView new];
// Show with GIF
// The 5th capture
[self.myactivityIndicatorView showWithGIFName:@"test.gif"];
然后当某些任务完成时,只需简单使用
[self.myactivityIndicatorView dismiss];
或者在消失之前显示一些文本
// The 1st capture
[self.myactivityIndicatorView dismissWithText:@"This is a sample dismiss text" delay:0.5];
注意
您不应在 viewDidLoad
中显示 CCActivityIndicatorView
,动画将不会工作!
相反,应在 viewWillAppear
或 viewDidAppear
中显示。
// Set public properties before showing it.
// Set the backgrond color. The default color is black.
self.myactivityIndicatorView.backColor = <#UIColor#>;
// Set the background border color. The default background color is black.
self.myactivityIndicatorView.borderColor = <#UIColor#>;
// Set the backgrond border width. THe default value is 0.
self.myactivityIndicatorView.borderWidth = <#CGFloat#>;
// Set the background corner radius. The default value is 10.0;
self.myactivityIndicatorView.cornerRadius = <#CGFloat#>;
// Set the indicator color. The default color is white.
self.myactivityIndicatorView.indicatorColor = <#UIColor#>;
// Set the boolean value that indicates whether the ohter UIViews are user-interactable. The default value is YES.
self.myactivityIndicatorView.isTheOnlyActiveView = <#BOOL#>;
// Set the appear animation type.
self.myactivityIndicatorView.appearAnimationType = <#CCIndicatorAppearAnimationType#>;
// Set the disappear animation type.
self.myactivityIndicatorView.disappearAnimationType = <#CCIndicatorDisappearAnimationType#>;
// Set the background view type
self.myactivityIndicatorView.backgroundViewType = <#CCIndicatorBackgroundViewType#>;
typedef NS_ENUM(NSInteger, CCIndicatorType) {
CCIndicatorTypeScalingDots, // Default type
CCIndicatorTypeLeadingDots,
CCIndicatorTypeCircle,
CCIndicatorTypeArc
};
typedef NS_ENUM(NSInteger, CCIndicatorAppearAnimationType) {
CCIndicatorAppearAnimationTypeSlideFromTop,
CCIndicatorAppearAnimationTypeSlideFromBottom,
CCIndicatorAppearAnimationTypeSlideFromLeft,
CCIndicatorAppearAnimationTypeSlideFromRight,
CCIndicatorAppearAnimationTypeZoomIn,
CCIndicatorAppearAnimationTypeFadeIn // Default type
};
typedef NS_ENUM(NSInteger, CCIndicatorDisappearAnimationType) {
CCIndicatorDisappearAnimationTypeSlideToTop,
CCIndicatorDisappearAnimationTypeSlideToBottom,
CCIndicatorDisappearAnimationTypeSlideToLeft,
CCIndicatorDisappearAnimationTypeSlideToRight,
CCIndicatorDisappearAnimationTypeZoomOut,
CCIndicatorDisappearAnimationTypeFadeOut // Default type
};
typedef NS_ENUM(NSInteger, CCIndicatorBackgroundViewType) {
CCIndicatorBackgroundViewTypeNone, // Default type
CCIndicatorBackgroundViewTypeBlur,
CCIndicatorBackgroundViewTypeTransparent,
CCIndicatorBackgroundViewTypeShadow
};
iOS 8.0 或更高版本
uiimage-from-animated-gif : 一个加载动画 GIF 的 UIImage 分类。
欢迎任何拉取请求。