-5

我想用删除按钮红色和取消按钮创建操作表相同的波纹管图片。我怎样才能做到这一点?非常感谢

我想用删除按钮红色和取消按钮创建操作表相同的波纹管图片。 我怎样才能做到这一点? 非常感谢

4

5 回答 5

4

只需使用该代码使删除按钮成为破坏性按钮

UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@"Are you sure you want to delete this backup?" delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:@"Delete Backup" otherButtonTitles:nil,nil];
actionSheet.actionSheetStyle = UIActionSheetStyleBlackOpaque;
[actionSheet showInView:self.view];
于 2013-07-17T06:28:29.067 回答
0
UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@"Are you sure you want to delete this backup ?" delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:@"Delete backup" otherButtonTitles:nil, nil];
    [actionSheet showInView:self.view];
于 2013-07-17T06:26:35.687 回答
0

试试下面的代码

  UIActionSheet *objActionSheet = [[UIActionSheet alloc]
                         initWithTitle:@"XYZ Message"
                         delegate:self
                         cancelButtonTitle:@"Cancel"
                         destructiveButtonTitle:@"Delete Backup"
                         otherButtonTitles:nil];
于 2013-07-17T06:29:36.757 回答
0

github 上有许多现成的代码可用于此类操作表。

  1. 适用于 iOS 的 RDActionSheet
  2. iOS 的操作表块
  3. 适用于 iOS 的 LBActionSheet
  4. 适用于 iOS 的 SHActionSheetBlocks
于 2013-07-17T06:48:00.523 回答
0

您可以从https://github.com/russj/MBActionSheet/下载示例项目,并可以自定义您的操作表。您可以使用以下代码设计按钮并添加到操作表

- (void)createButton:(CGRect)frm buttonTitile:(NSString *)title buttonIndex:(NSInteger)index
{
    UIButton *btn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    btn.frame = frm;
    if(index==0){
            [btn setBackgroundImage:[UIImage imageNamed:@"delete.png"] forState:UIControlStateNormal];
    }
    else if(index==1){
            [btn setBackgroundImage:[UIImage imageNamed:@"cancel.png"] forState:UIControlStateNormal];
    }

    [btn addTarget:self action:@selector(buttonClicked:) forControlEvents:UIControlEventTouchUpInside];
    [btn setTag:index];
    [sheetView addSubview:btn];
}

并在您创建操作表的地方调用此方法。

于 2013-07-17T06:57:45.633 回答