Navigation bar tint color changes after auto dimissal of UIAlertView

萝らか妹 提交于 2019-12-11 19:36:11

问题


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

When an alert or action sheet appears, iOS 7 automatically dims the tint color of the views behind it. To respond to this color change, a custom view subclass that uses tintColor in its rendering should override tintColorDidChange to refresh the rendering when appropriate.

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

回答1:


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;
    }
}


来源:https://stackoverflow.com/questions/21711405/navigation-bar-tint-color-changes-after-auto-dimissal-of-uialertview

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!