开源提示框SVProgressHUD使用备忘录 (五)

2014-11-24 03:28:15 · 作者: · 浏览: 4

self.hudView.bounds = CGRectMake(0, 0, hudWidth, hudHeight);

if(string)
self.imageView.center = CGPointMake(CGRectGetWidth(self.hudView.bounds)/2, 36);
else
self.imageView.center = CGPointMake(CGRectGetWidth(self.hudView.bounds)/2, CGRectGetHeight(self.hudView.bounds)/2);

self.stringLabel.hidden = NO;
self.stringLabel.text = string;
self.stringLabel.frame = labelRect;

if(string)
self.spinnerView.center = CGPointMake(ceil(CGRectGetWidth(self.hudView.bounds)/2)+0.5, 40.5);
else
self.spinnerView.center = CGPointMake(ceil(CGRectGetWidth(self.hudView.bounds)/2)+0.5, ceil(self.hudView.bounds.size.height/2)+0.5);
}

- (void)setFadeOutTimer:(NSTimer *)newTimer {

if(fadeOutTimer)
[fadeOutTimer invalidate], fadeOutTimer = nil;

if(newTimer)
fadeOutTimer = newTimer;
}


- (void)registerNotifications {
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(positionHUD:)
name:UIApplicationDidChangeStatusBarOrientationNotification
object:nil];

[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(positionHUD:)
name:UIKeyboardWillHideNotification
object:nil];

[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(positionHUD:)
name:UIKeyboardDidHideNotification
object:nil];

[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(positionHUD:)
name:UIKeyboardWillShowNotification
object:nil];

[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(positionHUD:)
name:UIKeyboardDidShowNotification
object:nil];
}


- (void)positionHUD:(NSNotification*)notification {

CGFloat keyboardHeight;
double animationDuration;

UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation];

if(notification) {
NSDictionary* keyboardInfo = [notification userInfo];
CGRect keyboardFrame = [[keyboardInfo valueForKey:UIKeyboardFrameBeginUserInfoKey] CGRectValue];
animationDuration = [[keyboardInfo valueForKey:UIKeyboardAnimationDurationUserInfoKey] doubleva lue];

if(notification.name == UIKeyboardWillShowNotification || notification.name == UIKeyboardDidShowNotification) {
if(UIInterfaceOrientationIsPortrait(orientation))
keyboar