问题描述
我想在路径或Facebook中创建一个幻灯片菜单,在我的菜单和UINavigationController之间有一个阴影,其中包含所有内容。我可以为图层添加圆角,但不会显示我应用于图层的阴影。这段代码有什么问题?如果我使用UIViewController而不是UINavigationController ...(代码在作为rootViewController添加到UINavigationController的视图中),它正在工作。
I want to create a Slide Menu like in Path or Facebook with a shadow between my menu and the UINavigationController with all the content inside. I can add rounded corners to the layer but the shadow I apply to the layer is not shown. What is wrong with that code? It is working if I use a UIViewController instead of the UINavigationController... (The code is inside a view added as rootViewController to the UINavigationController)
问题是我不知道我想要松开UINavigationController的圆形边框
The problem is that I don't want to loose the rounded borders of the UINavigationController
self.navigationController.view.layer.shadowPath = [UIBezierPath bezierPathWithRoundedRect:self.navigationController.view.bounds cornerRadius:self.navigationController.view.layer.cornerRadius].CGPath;
[self.navigationController.view.layer setMasksToBounds:YES];
[self.navigationController.view.layer setShadowColor:[UIColor blackColor].CGColor];
[self.navigationController.view.layer setShadowOffset:CGSizeMake(0, 0)];
[self.navigationController.view.layer setShadowOpacity:0.5];
[self.navigationController.view.layer setShadowRadius:3];
[self.navigationController.view.layer setCornerRadius:3];
推荐答案
在Swift3中
self.navigationController?.view.layer.shadowOffset = CGSize(width: 0, height: 5)
self.navigationController?.view.layer.masksToBounds = true
这篇关于如何向UINavigationController添加阴影的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!