How to customize UIActionSheet? iOS

后端 未结 7 1308
小蘑菇
小蘑菇 2020-12-04 12:38

Is it possible to create an ActionSheet that have a label between two buttons like this image?

\"ent

7条回答
  •  时光取名叫无心
    2020-12-04 13:24

    I was just going to add a small comment but i cant comment yet so ill post a full answer. If you want to avoid the IOS7 errors CGContextSetFillColorWithColor: invalid context 0x0. This is a serious error etc. You can use the following.

    self.actionSheet = [[UIActionSheet alloc] initWithTitle:@""
                                                   delegate:nil
                                          cancelButtonTitle:nil
                                     destructiveButtonTitle:nil
                                          otherButtonTitles:nil];
    

    However that will mess up the graphic/drawing at the top of your action sheet as @Max said so if you dont already have a background your adding just add this code to give you the default action sheet look.

    UIView *background = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 44)];
    background.backgroundColor = [UIColor colorWithRed:204.0/255.0 green:204.0/255.0 blue:204.0/255.0 alpha:1];
    [self.actionSheet addSubview:background];
    

    then add whatever else you want to your custom action sheet.

提交回复
热议问题