Skip to content

Customization for TKAlertCenter alerts - #213

Open
huguesbr wants to merge 2 commits into
devinross:masterfrom
huguesbr:master
Open

Customization for TKAlertCenter alerts#213
huguesbr wants to merge 2 commits into
devinross:masterfrom
huguesbr:master

Conversation

@huguesbr

Copy link
Copy Markdown

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.

1 participant