自动关闭UIAlertView后,导航栏的颜色会发生变化 [英] Navigation bar tint color changes after auto dimissal of UIAlertView

查看:62
本文介绍了自动关闭UIAlertView后,导航栏的颜色会发生变化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经编写了自定义UIAlertview,以在某些情况下允许自动解雇。现在,在iOS 7中,当自动关闭发生时,我的导航栏的颜色会发生变化。根据iOS7过渡指南:

I have written my custom UIAlertview to allow auto dismissal in certain cases. Now, with iOS 7 when auto dismissal happens the tint color of my nav bar changes. As per the iOS7 Transition Guide:

https://developer.apple.com/library/ios/documentation/userexperience/conceptual/transitionguide/TransitionGuide.pdf

当出现警报或操作表时,iOS 7会自动将其后面视图的色调变暗。为了响应这种颜色变化,在适当的渲染中使用tintColor的自定义视图子类应覆盖tintColorDidChange以在适当时刷新渲染。

只能在自定义UIAlertView中使用进行处理。以下是我用于自定义UIAlertView的代码:

Any idea if this can be handled from with in the custom UIAlertView only. Below is my code for custom UIAlertView:

#define kStartupFailAlert 203

#import "RunnerUIAlertView.h"

@implementation RunnerUIAlertView

- (id)init {
    self = [super init];

    if (self) {
        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(removeAlert) name:kRemoveVisibleAlert object:nil];
    }

    return self;
}


- (void)removeAlert {  
    if (self.tag != kStartupFailAlert) { // If not kRunnerStartupFailAlert - as it will be auto dismissed
        self.delegate = nil;
        NSInteger aCancelButtonIndex = [self cancelButtonIndex];
        [super dismissWithClickedButtonIndex:aCancelButtonIndex animated:NO];
    }
}


- (void)dealloc {
    [[NSNotificationCenter defaultCenter] removeObserver:self];
}

@end


推荐答案

通过在应用程序委托窗口上恢复色调设置来解决此问题。但是,这样做的副作用是,在打开弹出窗口或工作表时,不会使导航色的颜色变暗。似乎与iOS7 SDK有关。

Got this worked out by restoring the tint settings on app delegate's window. But then it has this side effect of not dimming the navigation tint color when opening a popover or a sheet. It seems be an issue with iOS7 SDK.

- (void)removeAlert {
    if (self.tag != kStartupFailAlert) { // If not kRunnerStartupFailAlert - as it will be auto dismissed
        self.delegate = nil;
        NSInteger aCancelButtonIndex = [self cancelButtonIndex];
        [self dismissWithClickedButtonIndex:aCancelButtonIndex animated:NO];

        MyAppDelegate *appDeletgate = [Utilities applicationDelegate];
        appDeletgate.window.tintAdjustmentMode = UIViewTintAdjustmentModeNormal;
    }
}

这篇关于自动关闭UIAlertView后,导航栏的颜色会发生变化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆