objectivec
//
// CCUIAlertActivityView.h
// CCFC
//
//
#import <Foundation/Foundation.h>
@interface CCUIAlertActivityView : UIView
{
UIAlertView *_alertView;
UIActivityIndicatorView *_activityView;
float _disappearTime;
}
// if set 0, then it won't disappear until you hide it.
@property(nonatomic, assign) float disappearTime;
- (id)initWithTitle:(NSString *)title;
- (void)dealloc;
- (void)show;
- (void)hide;
@end
objectivec
//
// CCUIAlertActivityView.m
// CCFC
//
//
#import "CCUIAlertActivityView.h"
#import "CCNSNumber.h"
#import "CCUIView.h"
#import "CCCommon.h"
#import "CCLog.h"
@implementation CCUIAlertActivityView
@synthesize disappearTime = _disappearTime;
- (id)initWithTitle:(NSString *)title
{
self = [super init];
if(self)
{
_alertView = [[UIAlertView alloc] initWithTitle:title
message:nil
delegate:self
cancelButtonTitle:nil
otherButtonTitles:nil];
_activityView = [[UIActivityIndicatorView alloc]
initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhite];
_activityView.frame = CGRectMake(0, 0, 20, 20);
[_alertView addSubview:_activityView];
[_activityView release];
}
return self;
}
- (void)dealloc
{
[super dealloc];
}
- (void)onDisappear:(id)timer PRIVATE_FLAG
{
[_activityView stopAnimating];
[_alertView dismissWithClickedButtonIndex:0 animated:YES];
}
- (void)show
{
[_alertView show];
[_activityView setCenterOf:_alertView];
[_activityView startAnimating];
[_alertView release];
if(!FLOAT_EQUAL_TO_ZERO(_disappearTime))
{
[NSTimer scheduledTimerWithTimeInterval:_disappearTime
target:self
selector:@selector(onDisappear:)
userInfo:nil
repeats:NO];
}
}
- (void)hide
{
[_alertView dismissWithClickedButtonIndex:0 animated:YES];
}
@end
微风不燥,阳光正好,你就像风一样经过这里,愿你停留的片刻温暖舒心。
我是程序员小迷(致力于C、C++、Java、Kotlin、Android、Shell、JavaScript、TypeScript、Python等编程技术的技巧经验分享),若作品对您有帮助,请关注、分享、点赞、收藏、在看、喜欢,您的支持是我们为您提供帮助的最大动力。
欢迎关注。助您在编程路上越走越好!