Wednesday, 8 May 2019

Set background image for UIAlertController







UIAlertController * alert=   [UIAlertController
                                  alertControllerWithTitle:@"Title" //alert Title
                                  message:@"Msg sfdgfdjsgajgasgasgsfjkgsfjkgfsgksdgfhvbhbdfjkvbsbvjsdfbvjsdbvbdsvbdjbvdbvdbjvdbjvbdsfbvj v hsfv hfs vhjsf vf hv sjfvbjs f" //Your Message
                                  preferredStyle:UIAlertControllerStyleAlert];
   
    UIView *firstSubview = alert.view.subviews.firstObject;
    UIView *alertContentView = firstSubview.subviews.firstObject;
    for (UIView *subSubView in alertContentView.subviews) {
        subSubView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"OTP.png"]];
    }

    UIAlertAction* ok = [UIAlertAction
                         actionWithTitle:@"OK"
                         style:UIAlertActionStyleDefault
                         handler:^(UIAlertAction * action)
                         {
                             [alert dismissViewControllerAnimated:YES completion:nil];
                           
                         }];
   
   
    [alert addAction:ok];
   
    [self presentViewController:alert animated:YES completion:nil];

No comments:

Post a Comment

Difference between == and ===

Difference between == and === https://stackoverflow.com/questions/24002819/difference-between-and == operator checks if their ...