如何删除UIPopoverController中的"模糊"投影

Arc*_*ian 5 uikit uipopovercontroller ios

当UIPopoverController的视图出现时,我不想要投影.有没有办法删除这个阴影外观?

nik*_*o34 12

不是直截了当,但是从iOS 5开始,您可以使用UIPopoverBackgroundView创建自己的自定义弹出窗口背景.

请参阅此问题的答案:使用UIPopoverBackgroundView类.它指向一个好的tuto.

然后,在UIPopoverBackgroundView实现的initWithFrame中,可以使用clearColor作为投影.使用偏移和半径对我来说不起作用.

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

        self.layer.shadowColor = [[UIColor clearColor] CGColor];
    }
    return self;
}
Run Code Online (Sandbox Code Playgroud)


Cal*_*leb 0

阴影是弹出视图图层的一个属性。如果您可以访问该图层,则可以将其阴影半径设置为 0.0,将阴影偏移设置为 {0.0, 0.0}。但是,看起来该视图必须是弹出窗口控制器的私有 ivar,因此没有一种简单的方法可以访问它。此外,如果您希望通过应用程序商店分发此应用程序,那么使用私有 ivar 并更改标准 UI 元素的外观都可能导致您的应用程序被拒绝。