How to customize UIActionSheet? iOS

2019-01-13 01:24发布

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

enter image description here

Really need this right now. Can anyone help me? Thanks.

7条回答
相关推荐>>
2楼-- · 2019-01-13 01:50

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.

查看更多
登录 后发表回答