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

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

相关推荐
YungFan9 小时前
iOS26适配指南之UIButton
ios·swift
红橙Darren14 小时前
手写操作系统 - 编译链接与运行
android·ios·客户端
鹏多多.17 小时前
flutter-使用device_info_plus获取手机设备信息完整指南
android·前端·flutter·ios·数据分析·前端框架
麦兜*1 天前
【swift】SwiftUI动画卡顿全解:GeometryReader滥用检测与Canvas绘制替代方案
服务器·ios·swiftui·android studio·objective-c·ai编程·swift
GeniuswongAir2 天前
iOS 26 一键登录失效:三大运营商 SDK 无法正常获取手机号
ios
吴Wu涛涛涛涛涛Tao2 天前
Flutter 实现类似抖音/TikTok 的竖向滑动短视频播放器
android·flutter·ios
猪哥帅过吴彦祖2 天前
Flutter 插件工作原理深度解析:从 Dart 到 Native 的完整调用链路
android·flutter·ios
归辞...2 天前
「iOS」————UITableView性能优化
ios·性能优化·cocoa
AI工具测评与分析2 天前
EhViewer安卓ios全版本类下载安装工具的完整路径解析
android·ios