ios CCUIAlertActivityView.m

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等编程技术的技巧经验分享),若作品对您有帮助,请关注、分享、点赞、收藏、在看、喜欢,您的支持是我们为您提供帮助的最大动力。

欢迎关注。助您在编程路上越走越好!

相关推荐
恋猫de小郭15 小时前
什么?Flutter 可能会被 SwiftUI/ArkUI 化?全新的 Flutter Roadmap
flutter·ios·swiftui
网安墨雨19 小时前
iOS应用网络安全之HTTPS
web安全·ios·https
福大大架构师每日一题20 小时前
37.1 prometheus管理接口源码讲解
ios·iphone·prometheus
BangRaJun2 天前
LNCollectionView-替换幂率流体
算法·ios·设计
刘小哈哈哈2 天前
iOS 多个输入框弹出键盘处理
macos·ios·cocoa
靴子学长2 天前
iOS + watchOS Tourism App(含源码可简单复现)
mysql·ios·swiftui
一如初夏丿2 天前
xcode15 报错 does not contain ‘libarclite‘
ios·xcode
杨武博3 天前
ios 混合开发应用白屏问题
ios
BangRaJun3 天前
LNCollectionView
android·ios·objective-c
二流小码农3 天前
鸿蒙元服务项目实战:终结篇之备忘录搜索功能实现
android·ios·harmonyos