Change Action sheet popover arrow in iOS8

后端 未结 4 1226
挽巷
挽巷 2021-02-07 01:13

i\'m using UIAlertController . But on iPad with iOS 8, actionSheet show with popover arrow. Any ideas to hide that arrow?

Here is my code:

         


        
4条回答
  •  佛祖请我去吃肉
    2021-02-07 01:54

    Solution :
    use below line for remove arrow from action sheet

    [yourAlertController.popoverPresentationController setPermittedArrowDirections:0];
    


    Sample

    UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"Test Action Sheet" message:@"Message" preferredStyle:UIAlertControllerStyleActionSheet];
    
        UIAlertAction *cancelAction = [UIAlertAction
                                       actionWithTitle:@"Cancel"
                                       style:UIAlertActionStyleDestructive
                                       handler:^(UIAlertAction *action)
                                       {
                                           NSLog(@"Cancel action");
                                       }];
    
        UIAlertAction *okAction = [UIAlertAction
                                   actionWithTitle:@"Ok"
                                   style:UIAlertActionStyleDefault
                                   handler:^(UIAlertAction *action)
                                   {
                                       NSLog(@"OK action");
                                   }];
        UIAlertAction *otherAction = [UIAlertAction
                                   actionWithTitle:@"Other"
                                   style:UIAlertActionStyleDefault
                                   handler:^(UIAlertAction *action)
                                   {
                                       NSLog(@"Otheraction");
                                   }];
    
        [alertController addAction:okAction];
        [alertController addAction:otherAction];
        [alertController addAction:cancelAction];
    
    
        // Remove arrow from action sheet.
        [alertController.popoverPresentationController setPermittedArrowDirections:0];
    
        //For set action sheet to middle of view.
        alertController.popoverPresentationController.sourceView = self.view;
        alertController.popoverPresentationController.sourceRect = self.view.bounds;
    
        [self presentViewController:alertController animated:YES completion:nil];
    

    Output

    enter image description here

提交回复
热议问题