【发布时间】:2010-11-28 03:34:11
【问题描述】:
我在我的 iphone 应用程序中使用标准弹出操作(屏幕底部的弹出)。这有 2 个按钮“确定”和“取消”。似乎标准的配色方案是将顶部按钮设置为红色。我想改变这个,所以顶部的按钮是绿色的。我一直在谷歌搜索,找不到解决方案。任何想法都会很棒。谢谢
【问题讨论】:
我在我的 iphone 应用程序中使用标准弹出操作(屏幕底部的弹出)。这有 2 个按钮“确定”和“取消”。似乎标准的配色方案是将顶部按钮设置为红色。我想改变这个,所以顶部的按钮是绿色的。我一直在谷歌搜索,找不到解决方案。任何想法都会很棒。谢谢
【问题讨论】:
您可以浏览 ActionSheet(我假设您使用 UIActionSheet 类)子视图 - 就像这样:
NSArray* subViews = [aSheet subviews];
for (UIView* sView in subViews)
{
...
}
并根据需要更改那里的子视图属性。
您也可以创建不带任何按钮的 UIActionSheet:
UIActionSheet* aSheet = [[UIActionSheet alloc] initWithTitle:@"\n\n\n" delegate:self cancelButtonTitle:nil destructiveButtonTitle:nil otherButtonTitles:nil];
然后创建您自己的自定义按钮并将它们添加到 ActionSheet 视图中。 (在标题中添加更多 \n 以放大工作表高度)
【讨论】:
我假设您指的是 UIActionSheet。在 UIActionSheet 中,您可以定义取消操作并具有黑色背景的按钮、标记破坏性操作并具有红色背景的按钮以及具有白色背景的所有其他按钮。在 UIActionSheet 的初始化中,可以使用– initWithTitle:delegate:cancelButtonTitle:destructiveButtonTitle:otherButtonTitles: 指定哪个选项对应哪个类的动作。
iPhone Human Interface Guidelines 中解释了 UIActionSheet 的设计,包括为什么您应该只为按钮使用这些颜色。在这方面我会遵循 Apple 的建议,因为它们会使您的应用程序更易于使用。
【讨论】:
UIActionSheet *action = [[UIActionSheet alloc] initWithTitle:@""
delegate:self
cancelButtonTitle:@"Cancel"
destructiveButtonTitle:nil,@"Mail",@"Facebook",@"Twitter",nil
otherButtonTitles:nil];
NSArray *buttons = [action subviews];
【讨论】: