如何在UIActionSheet中编码绿色按钮?

Jos*_*hua 5 iphone cocoa-touch button uikit uiactionsheet

我正在使用代码:

  {
        randomstatus=0;
        msg=[[NSString alloc]initWithFormat:@"Good job, do you want to continue?"];
        UIActionSheet *actionSheet=[[UIActionSheet alloc]initWithTitle:msg delegate:self cancelButtonTitle:@"No" destructiveButtonTitle:@"Yes" otherButtonTitles:nil];
        [actionSheet showInView:self.view];
        [actionSheet release];
        [msg release];
    }   
Run Code Online (Sandbox Code Playgroud)

我不想更改代码,但我需要"destructiveButton"为绿色而不是红色.这是可能的,还是我需要使用不同的按钮?

Eri*_*ler 2

不幸的是,没有任何官方提供的方法来自定义 UIActionSheet 按钮。

但是,您可以访问 UIActionSheet 的子视图(这可能会在将来的 iPhone OS 更新中中断),或者添加一个带有覆盖原始破坏性操作按钮的按钮的新视图(这可能会再次中断)。

虽然与更改 UIActionSheet 上按钮的颜色没有直接关系,但上一个问题:iPhone 禁用 UIActionSheet 按钮演示了向 UIActionSheet 添加自定义视图的几种方法。