如何向UINavigationController添加阴影

编程入门 行业动态 更新时间:2024-10-22 13:41:17
本文介绍了如何向UINavigationController添加阴影的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我想在路径或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添加阴影

本文发布于:2023-11-12 03:51:47,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1580435.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:阴影   UINavigationController

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!