如何删除iOS 9上的popovers背后的阴影?

问题描述 投票:10回答:2

在iOS 8中,弹出窗口没有阴影。现在在iOS 9中,有一个非常沉重且影响深远的阴影,在纯白色背景上看起来不太理想。如何去除阴影,而是在弹出窗口周围添加一条细细的灰色线条?或者至少减少或减轻。

当显示动作表,使用.Popover UIModalPresentationStyle呈现视图控制器时,以及可能在其他情况下,会发生这种情况。

Popover如下:enter image description here

行动表:

UIActionSheet(title: "Title", delegate: nil, cancelButtonTitle: "Cancel", destructiveButtonTitle: "Destroy").showInView(sender as! UIView)

enter image description here

ios uipopovercontroller popover ios9
2个回答
8
投票

您可以使用UIPopoverBackgroundView制作自己的自定义弹出窗口背景

在你的initWithFrame实现的UIPopoverBackgroundView中,你可以使用[UIColor clearColor作为投影。

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {

        self.layer.shadowColor = [[UIColor clearColor] CGColor];
    }

    return self;
}

0
投票

Swift 4版本接受了答案。

override init(frame: CGRect) {
    super.init(frame: frame)    
    layer.shadowColor = UIColor.clear.cgColor
}

required init?(coder aDecoder: NSCoder) {
    fatalError("init(coder:) has not been implemented")
}
最新问题
© www.soinside.com 2019 - 2025. All rights reserved.