How can i Change the frame of uialertaction in uialertcontroller in objective c

1.1k views Asked by At

I am adding the alertView in whole application. and i want to change the size of ok or cancel button in alertView so that i can set the small image of actions.

Anyone please help me for this.

2

There are 2 answers

0
TheHungryCub On

You can not change the size of ok or cancel button in alertView.

The only solution that I could figure is to make a custom view with UIVisualEffect and show it like UIActionSheet

Welcome if other solution is there :)

if you want to do this for adding image, then try following way:

UIAlertController * view=   [UIAlertController
                             alertControllerWithTitle:@"Add Image"
                             message:@"Image Added successfully"
                             preferredStyle:UIAlertControllerStyleActionSheet];


UIAlertAction* add = [UIAlertAction
                     actionWithTitle:@"add"
                     style:UIAlertActionStyleDefault
                     handler:^(UIAlertAction * action)
                     {
                         //Do some thing here
                         [view dismissViewControllerAnimated:YES completion:nil];

                     }];
[add setValue:[[UIImage imageNamed:@"add.png"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] forKey:@"image"];
[view addAction:add];
[self presentViewController:view animated:YES completion:nil];
0
Yogesh Mv On

You cannot change the frame of default Alert view for this you have to use custom alert view. Please refer the below links for custom alert views

  1. https://github.com/dogo/SCLAlertView
  2. https://github.com/vikmeup/SCLAlertView-Swift (Swift)
  3. https://github.com/mtonio91/AMSmoothAlert