Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/38.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/118.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vue.js/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone UIViewController中的阴影错误_Iphone_Ios_Ios5 - Fatal编程技术网

Iphone UIViewController中的阴影错误

Iphone UIViewController中的阴影错误,iphone,ios,ios5,Iphone,Ios,Ios5,我用这段代码在UIViewcontroller中获得阴影效果 在我看来 // Add drop shadow to the view. CAGradientLayer *gradientLayer = [CAGradientLayer layer]; gradientLayer.frame = CGRectMake(0, 0, 90, self.view.frame.size.height); gradientLayer.colors = [NSA

我用这段代码在UIViewcontroller中获得阴影效果 在我看来

// Add drop shadow to the view.
        CAGradientLayer *gradientLayer = [CAGradientLayer layer];
        gradientLayer.frame = CGRectMake(0, 0, 90, self.view.frame.size.height);
        gradientLayer.colors = [NSArray arrayWithObjects:
                                (id)[UIColor lightGrayColor].CGColor,
                                (id)[UIColor clearColor].CGColor,
                                nil];
        gradientLayer.startPoint = CGPointMake(-7, 0.1);
        gradientLayer.endPoint = CGPointMake(1, 0.15);   
        [self.view.layer addSublayer:gradientLayer];
我在视图中获得了正确的阴影,但问题是当我转到另一个视图控制器并返回时,每次显示都越来越暗。我使用UIPopOverController导航到另一个视图

我的代码有什么问题?
提前感谢。

我刚刚用您的精确代码运行了一些测试,它工作正常。我可以复制您遇到的问题的唯一方法是将代码放入
viewwillbeen:
viewdidebeen:
。您是否可能在这些函数中有一些代码正在绘制阴影?

不确定这是否有帮助,但当我开始使用UIPopOver控制器时,我遇到了与您完全相同的情况

这是因为每次我激活新的popover时,我都会一次又一次地覆盖它,而不是移除旧的popover。所以看起来阴影一次比一次暗

当您移动到另一个视图时,您是在移除PopOver还是将其留在后面


只是想一想。

当你移动到下一个视图时,请删除你的GradientLayerHai,谢谢你的回复,,,我将此代码放在viewdidload方法中。是否有任何东西会导致每次视图返回时调用viewDidLoad?您实际上是如何转换视图的?UINavigationController?我从你的帖子中看到了,但没有上下文,这并不意味着什么。视图上的阴影是否在popover内?当有人在popover中选择一个项目时,会发生什么?他们会去另一个地方吗?如果是这样的话,你在使用什么命令?当我在弹出框中选择一个按钮时,它会消失,并根据该按钮更改主页文本单击,我会发出通知删除弹出框。问题不是当我在代码中插入阴影图像时,我会得到相同的错误,图像会变大或变暗