简体   繁体   English

如何为UIActionSheet设置背景颜色

[英]How to set background color for UIActionSheet

In the following method 在以下方法

- (void)willPresentActionSheet:(UIActionSheet *)actionSheet{

I have set: 我已经设定:

[button setBackgroundColor:[UIColor redColor]];

This is for one button. 这是一个按钮。 But here is what I get: 但是我得到的是:

在此处输入图片说明

What I want to know is how to set the color only on button without the side gaps ? 我想知道的是如何仅在按钮上设置颜色而没有侧面间隙?

Any guidance or help is appreciated. 任何指导或帮助表示赞赏。

Thanks. 谢谢。

If you want to change the title color use the below code. 如果要更改标题颜色,请使用以下代码。

for (UIView *view in actionSheet.subviews) {
    if ([view isKindOfClass:[UIButton class]]) {
        UIButton *button = (UIButton *)view;
        [button setTitleColor:[UIColor redColor] forState:UIControlStateNormal];

    }
}

I also need the custom UIAcionSheet but default actionsheet doesn't support the customization functionality so i used the other customer controller UICustomActionSheet and got the expected result like 我还需要自定义UIAcionSheet,但默认操作表不支持自定义功能,因此我使用了其他客户控制器UICustomActionSheet并获得了预期的结果,例如

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM