iPad上的UIActionSheet backGroundColor [英] UIActionSheet backGroundColor on iPad

查看:125
本文介绍了iPad上的UIActionSheet backGroundColor的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我现在已经用了很长一段时间了。由于我没有真正找到解决方案,我希望有人能够帮助我。

I'm struggeling with an issuse for quite a while now. Since I don't really find a solution, I hope somebody here will be able to help me.

我有一个UIActionSheet我希望有不同的背景颜色。
随着

I have a UIActionSheet that I want to have a different background color. With

[[myAlert layer] setBackgroundColor:[UIColor redColor] .CGColor];

我能够改变大部分警报的颜色。
这是它的样子:

I am able to change most of the alert's color. This is how it looks like:

这是我初始化UIActionSheet的方式:

This is how I initialize the UIActionSheet:

    UIActionSheet *styleAlert = [[UIActionSheet alloc] initWithTitle:AMLocalizedString(@"SELECT_PICTURE_TITLE", @"Überschrift des Actionsheets")
                                                            delegate:self
                                                   cancelButtonTitle:AMLocalizedString(@"CANCEL_BUTTON_TITLE", @"Abbrechen butten")
                                              destructiveButtonTitle:nil
                                                   otherButtonTitles:AMLocalizedString(@"TAKE_PICTURE_BUTTON_TITLE", @"Bild aufnehmen button"),
                                 AMLocalizedString(@"CAMERA_ROLL_BUTTON_TITLE", @"Aus Bibliothek auswählen"), nil];

    // use the same style as the nav bar
    [styleAlert showInView:self.parentViewController.tabBarController.view];
    //[styleAlert showInView:[self.navigationController view] ];
    [styleAlert release];

- (void)willPresentActionSheet:(UIActionSheet *)actionSheet {
    actionSheet.layer.backgroundColor = GLOBAL_TINT_COLOR.CGColor;
}

我无法弄清楚如何设置相同颜色的边框。有什么想法吗?

I could not figure out how to set the border with the same color. Any ideas?

提前致谢!

推荐答案

你可以'重新绘制不同颜色的边框,所以只需删除边框并添加自己的边框:

You can't redraw the border in a different color, so just remove the border and add your own:

- (void)didPresentActionSheet:(UIActionSheet *)actionSheet {
    UIView *contentView = actionSheet.superview;
    UIView *popoverView = contentView.superview;

    UIView *chromeView;
    for (UIView *v in [popoverView subviews]) {
        if (v.subviews.count == 3) {
            chromeView = v;
            break;
        }
    }

    for (UIView *backgroundComponentView in [chromeView subviews]) {
        backgroundComponentView.hidden = YES;

        CGRect componentFrame = backgroundComponentView.frame;  // add your view with this frame
    }
}

注意这个由于 actionSheet 在此时没有设置 superview ,因此无法在* will * PresentActionSheet中使用。

Note that this won't work in *will*PresentActionSheet since actionSheet doesn't have a superview set at that point.

这篇关于iPad上的UIActionSheet backGroundColor的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆