Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Customization for TKAlertCenter alerts #213

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

huguesbr
Copy link

AlertCenter is pretty cool, but you can't customize alert.

Instead of exposing alertView class. I've decided to add two methods (alertFont, alertTextColor, alertBackgroundColor) on AlertCenter itself.

Both method are proxy to alertCenter's alertView, and can be change at time any time (the alert is redraw each time it's shown).

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    [self.window makeKeyAndVisible];

/*
 Be aware that accessing defaultCenter before window is visible will capture an invalid frame.
 via _alertFrame = [UIApplication sharedApplication].keyWindow.bounds in [TKAlertCenter init]
*/
    [TKAlertCenter defaultCenter].alertTextFont = [UIFont boldSystemFontOfSize:19]; 
    [TKAlertCenter defaultCenter].alertTextFont = [UIFont boldSystemFontOfSize:19]; 
    [TKAlertCenter defaultCenter].alertBackgroundColor = [UIColor redColor];

    return YES;
}

I've also move default alertFont, alertTextColor and alertBackgroundColor to constants in top of TKAlertCenter.m.

…enter.

Both method are proxy to alertCenter's alertView, and can be change at time any time (the alert is redraw each time it's shown).
[TKAlertCenter defaultCenter].alertTextFont = [UIFont boldSystemFontOfSize:19]; [TKAlertCenter defaultCenter].alertBackgroundColor = [UIColor redColor];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant