首页 文章

uiactionsheet的背景颜色

提问于
浏览
2

我尝试更改动作表的背景颜色,我只是使用方法:

[actionSheet setBackgroundColor:[UIColor colorWithRed:30 green:30 blue:30 alpha:0.5]];

我把它放在willPresentActionSheet中 . 但背景颜色不变,为什么?

2 回答

  • 1

    您可以参考现有的stackoverflow post谈论改变动作表着色的技巧 .

  • 12
    • 添加QuartzCore.framework

    • 为您的操作表设置委托

    • 为动作表设置样式:UIActionSheetStyleBlackTranslucent

    • 覆盖方法willPresentActionSheet

    #import "QuartzCore/QuartzCore.h"
    ...
    
    yourActionSheet.delegate = self;
    yourActionSheet.actionSheetStyle = UIActionSheetStyleBlackTranslucent;
    ...
    
    - (void)willPresentActionSheet:(UIActionSheet *)actionSheet {
        [[actionSheet layer] setBackgroundColor:[UIColor redColor].CGColor];
    }
    

相关问题