Is there any way to customize the buttons
of uialertcontroller
? I have seen how to customize font, size and color but cannot add a background image or color of uialertcontroller button.
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:nil
message:nil
preferredStyle:UIAlertControllerStyleAlert];
UIViewController *v = [[UIViewController alloc] init];
v.view.backgroundColor = [UIColor cyanColor];
[alertController setValue:v forKey:@"contentViewController"];
UIAlertAction *selectImage = [UIAlertAction
actionWithTitle:@"First Button"
style:UIAlertActionStyleDefault
handler:^(UIAlertAction *action){
NSLog(@"First Button");
}];
[alertController addAction:selectImage];
UIAlertAction *addImage = [UIAlertAction
actionWithTitle:@"Second Button"
style:UIAlertActionStyleDefault
handler:^(UIAlertAction *action) {
NSLog(@"Second Button");
}];
[alertController addAction:addImage];
alertController.view.tintColor = [UIColor redColor];
UIView *subView = alertController.view.subviews.firstObject;
UIView *alertContentView = subView.subviews.firstObject;
[alertContentView setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"image.png"]]];
alertContentView.layer.cornerRadius = 5;
[self presentViewController:alertController animated:YES completion:nil];
Please suggest if there is any way to set background image of buttons.