从ViewController中删除阴影

时间:2016-05-19 10:32:31

标签: ios objective-c uinavigationcontroller calayer uibezierpath

我使用以下代码显示阴影。

UIBezierPath *shadowPath = [UIBezierPath bezierPathWithRect:CGRectMake(317, 0, 1, self.navigationController.view.frame.size.height)];
        self.navigationController.view.superview.layer.masksToBounds = NO;
        self.navigationController.view.layer.shadowColor = [UIColor blackColor].CGColor;
        self.navigationController.view.layer.shadowOffset = CGSizeMake(3, 0);  /*Change value of X n Y as per your need of shadow to appear to like right bottom or left bottom or so on*/
        self.navigationController.view.layer.shadowOpacity = 0.5f;
        self.navigationController.view.layer.shadowPath = shadowPath.CGPath;

我想删除这个影子。我尝试了一些但不工作的东西?任何帮助表示赞赏。

2 个答案:

答案 0 :(得分:0)

尝试将balckColor替换为clearColor和Opacity为0.0

self.navigationController.view.layer.shadowColor = [UIColor clearColor].CGColor;
self.navigationController.view.layer.shadowOpacity = 0.0f;

答案 1 :(得分:0)

你不能将不透明度设置为0.0。

self.navigationController.view.layer.shadowOpacity = 0.0;

谢谢!