Reputation: 937
As in iOS8 UIAlertView
is deprecated.we should use UIAlertController
.
I want to customize it like font color, font family of message label of alertcontrller's view, also change background color of ok button.i don't know the right way to do that.
Please Help!!
Any help will be appreciable!!
Upvotes: 1
Views: 16092
Reputation: 10752
I think, you have been perform task with them. But I think it's useful for someone.
Below code is working perfectly with my requirements. Please do changes according to your requirements.
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:nil
message:nil
preferredStyle:UIAlertControllerStyleActionSheet];
UIAlertAction *setCoverPhoto = [UIAlertAction
actionWithTitle:@"First Button"
style:UIAlertActionStyleDefault
handler:^(UIAlertAction *action){
NSLog(@"First Button");
}];
[alertController addAction:setCoverPhoto];
UIAlertAction *deleteImageAct = [UIAlertAction
actionWithTitle:@"Second Button"
style:UIAlertActionStyleDefault
handler:^(UIAlertAction *action) {
NSLog(@"Second Button");
}];
[alertController addAction:deleteImageAct];
UIAlertAction *setImageASNotif = [UIAlertAction
actionWithTitle:@"Third Button"
style:UIAlertActionStyleDefault
handler:^(UIAlertAction *action) {
NSLog(@"Third Button");
}];
[alertController addAction:setImageASNotif];
alertController.view.tintColor = [UIColor whiteColor];
UIView *subView = alertController.view.subviews.firstObject;
UIView *alertContentView = subView.subviews.firstObject;
[alertContentView setBackgroundColor:[UIColor darkGrayColor]];
alertContentView.layer.cornerRadius = 5;
[self presentViewController:alertController animated:YES completion:nil];
Upvotes: 2
Reputation: 19524
Pretty darn good tutorial over at Matt Thompson's site:
http://nshipster.com/uialertcontroller/
Also, how to configure the alert on the iOS Developer Library:
Upvotes: 1