削除ボタンの赤い色とキャンセルボタンを備えたアクションシートと同じ下図を作成したいと思います。どうやってやるの?どうもありがとう

削除ボタンの赤い色とキャンセルボタンを備えたアクションシートと同じ下図を作成したいと思います。どうやってやるの?どうもありがとう

そのコードを使用して、削除ボタンを破壊ボタンとして作成するだけです
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];
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];
サンプル プロジェクトは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];
}
アクションシートを作成している場所でこのメソッドを呼び出します。
このタイプのアクション シート用に、github で利用可能な多くの準備が整ったコードがあります。
以下のコードを試してください
UIActionSheet *objActionSheet = [[UIActionSheet alloc]
initWithTitle:@"XYZ Message"
delegate:self
cancelButtonTitle:@"Cancel"
destructiveButtonTitle:@"Delete Backup"
otherButtonTitles:nil];