开源提示框SVProgressHUD使用备忘录
[cpp]
//
// SVProgressHUD.h
//
// Created by Sam Vermette on 27.03.11.
// Copyright 2011 Sam Vermette. All rights reserved.
//
// https://github.com/samvermette/SVProgressHUD
//
#import <UIKit/UIKit.h>
#import <AvailabilityMacros.h>
enum {
SVProgressHUDMaskTypeNone = 1, // allow user interactions while HUD is displayed(允许用户进行其他界面操作)
SVProgressHUDMaskTypeClear, // don't allow(不允许用户进行其他界面操作)
SVProgressHUDMaskTypeBlack, // don't allow and dim the UI in the back of the HUD(不允许用户进行其他界面操作)
SVProgressHUDMaskTypeGradient // don't allow and dim the UI with a a-la-alert-view bg gradient(不允许用户进行其他界面操作)
};
typedef NSUInteger SVProgressHUDMaskType;
@inte易做图ce SVProgressHUD : UIView
// 下列函数展示提示框
+ (void)show;
+ (void)showWithStatus:(NSString*)status;
+ (void)showWithStatus:(NSString*)status maskType:(SVProgressHUDMaskType)maskType;
+ (void)showWithMaskType:(SVProgressHUDMaskType)maskType;
+ (void)showSuccessWithStatus:(NSString*)string;
+ (void)showSuccessWithStatus:(NSString *)string duration:(NSTimeInterval)duration;
+ (void)showErrorWithStatus:(NSString *)string;
+ (void)showErrorWithStatus:(NSString *)string duration:(NSTimeInterval)duration;
// 改变当前正在展示的提示框文字
+ (void)setStatus:(NSString*)string; // change the HUD loading status while it's showing
// 下列函数关闭当前提示
+ (void)dismiss; // simply dismiss the HUD with a fade+scale out animation
+ (void)dismissWithSuccess:(NSString*)successString; // also displays the success icon image
+ (void)dismissWithSuccess:(NSString*)successString afterDelay:(NSTimeInterval)seconds;
+ (void)dismissWithError:(NSString*)errorString; // also displays the error icon image
+ (void)dismissWithError:(NSString*)errorString afterDelay:(NSTimeInterval)seconds;
+ (BOOL)isVisible;
@end
//
// SVProgressHUD.h
//
// Created by Sam Vermette on 27.03.11.
// Copyright 2011 Sam Vermette. All rights reserved.
//
// https://github.com/samvermette/SVProgressHUD
//
#import <UIKit/UIKit.h>
#import <AvailabilityMacros.h>
enum {
SVProgressHUDMaskTypeNone = 1, // allow user interactions while HUD is displayed(允许用户进行其他界面操作)
SVProgressHUDMaskTypeClear, // don't allow(不允许用户进行其他界面操作)
SVProgressHUDMaskTypeBlack, // don't allow and dim the UI in the back of the HUD(不允许用户进行其他界面操作)
SVProgressHUDMaskTypeGradient // don't allow and dim the UI with a a-la-alert-view bg gradient(不允许用户进行其他界面操作)
};
typedef NSUInteger SVProgressHUDMaskType;
@inte易做图ce SVProgressHUD : UIView
// 下列函数展示提示框
+ (void)show;
+ (void)showWithStatus:(NSString*)status;
+ (void)showWithStatus:(NSString*)status maskType:(SVProgressHUDMaskType)maskType;
+ (void)showWithMaskType:(SVProgressHUDMaskType)maskType;
+ (void)showSuccessWithStatus:(NSString*)string;
+ (void)showSuccessWithStatus:(NSString *)string duration:(NSTimeInterval)duration;
+ (void)showErrorWithStatus:(NSString *)string;
+ (void)showErrorWithStatus:(NSString *)string duration:(NSTimeInterval)duration;
// 改变当前正在展示的提示框文字
+ (void)setStatus:(NSString*)string; // change the HUD loading status while it's showing
// 下列函数关闭当前提示
+ (void)dismiss; // simply dismiss the HUD with a fade+scale out animation
+ (void)dismissWithSuccess:(NSString*)successString; // also displays the success icon image
+ (void)dismissWithSuccess:(NSString*)successString afterDelay:(NSTimeInterval)seconds;
+ (void)dismissWithError:(NSString*)errorString; // also displays the error icon image
+ (void)dismissWithError:(NSString*)errorString afterDelay:(NSTimeInterval)seconds;
+ (BOOL)isVisible;
@end
[cpp]
//
// SVProgressHUD.m
//
// Created by Sam Vermette on 27.03.11.
// Copyright 2011 Sam Vermette. All rights reserved.
//
// https://github.com/samvermette/SVProgressHUD
//
#import "SVProgressHUD.h"
#import <QuartzCore/QuartzCore.h>
@inte易做图ce SVProgressHUD ()
@property (nonatomic, readwrite) SVProgressHUDMaskType maskType;
@property (nonatomic, strong, readonly) NSTimer *fadeOutTimer;
@property (nonatomic, strong, readonly) UIWindow *overlayWindow;
@property (nonatomic, strong, readonly) UIView *hudView;
@property (nonatomic, strong, readonly) UILabel *stringLabel;
@property (nonatomic, strong, readonly) UIImageView *imageView;
@property (nonatomic, strong, readonly) UIActivityIndicatorView *spinnerView;
@property (nonatomic, readonly) CGFloat visibleKeyboardHeight;
- (void)showWithStatus:(NSString*)string maskType:(SVProgressHUDMaskType)hudMaskType networkIndicator:(BOOL)show;
- (void)setStatus:(NSString*)string;
- (void)registerNotifications;
- (void)moveToPoint:(CGPoint)newCenter rotateAngle:(CGFloat)angle;
- (void)positionHUD:(NSNotification*)notification;
- (void)dismiss;
- (void)dismissWithStatus:(NSString*)string error:(BOOL)error;
- (void)dismissWithStatus:(NSString*)string error:(BOOL)error afterDelay:(NSTimeInterval)seconds;
@end
@implementation SVProgressHUD
@synthesize overlayWindow, hudView, maskType, fadeOutTimer, stringLabel, imageView, spinnerView, visibleKeyboardHeight;
- (void)dealloc {
self.fadeOutTimer = nil;
[[NSNotificationCenter defaultCenter] removeObserver:self];
}
+ (SVProgressHUD*)sharedView {
static dispatch_once_t once;
static SVProgressHUD *sharedView;
dispatch_once(&once, ^ { sharedView = [[SVProgressHUD alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; });
return sharedView;
}
+ (void)setStatus:(NSString *)string {
[[SVProgressHUD sharedView] setStatus:string];
}
#pragma mark - Show Methods
+ (void)show {
[[SVProgressHUD sharedView] showWithStatus:nil maskType:SVProgressHUDMaskTypeNone networkIndicator:NO];
}
+ (void)s
补充:软件开发 , C++ ,