-1
A
回答
1
我已通过添加导航栏下方的视图这样做过。
func addShadowToBar() {
let shadowView = UIView(frame: self.navigationController!.navigationBar.frame)
shadowView.backgroundColor = UIColor.whiteColor()
shadowView.layer.masksToBounds = false
shadowView.layer.shadowOpacity = 0.4 // your opacity
shadowView.layer.shadowOffset = CGSize(width: 0, height: 2) // your offset
shadowView.layer.shadowRadius = 4 //your radius
self.view.addSubview(shadowView)
}
1
斯威夫特3:
let shadowView = UIView(frame: navBar.frame)
shadowView.backgroundColor = UIColor.white
shadowView.layer.masksToBounds = false
shadowView.layer.shadowColor = UIColor.lightGray.cgColor
shadowView.layer.shadowOpacity = 0.8
shadowView.layer.shadowOffset = CGSize(width: 0, height: 2.0)
shadowView.layer.shadowRadius = 2
view.addSubview(shadowView)
1
,如果我没看错的,默认的导航栏已经带有了一层阴影。但是,如果你正在做一个自定义的与一个UIView,那么你应该这样做,使您的生活更轻松
yourView.clipsToBounds = false
yourView.layer.shadowOffset.height = 5 //this is your offset
yourView.layer.shadowOpacity = 0.25 //opacity of your shadow (recommended)
11
不添加视图
self.navigationController?.navigationBar.layer.masksToBounds = false
self.navigationController?.navigationBar.layer.shadowColor = UIColor.lightGray.cgColor
self.navigationController?.navigationBar.layer.shadowOpacity = 0.8
self.navigationController?.navigationBar.layer.shadowOffset = CGSize(width: 0, height: 2.0)
self.navigationController?.navigationBar.layer.shadowRadius = 2
+0
我尝试此代码和其他代码也是问题是,当我使用此导航变成浅灰色的颜色。但我想用白色和按钮阴影导航。 – chetu
相关问题
- 1. 阴影变色导航栏
- 2. 快速导航栏行为
- 3. 在mmdrawercontroller中快速隐藏导航栏
- 4. Pinterest导航栏框阴影css
- 5. 与添加一个阴影导航栏
- 6. Android底部导航栏带阴影
- 7. 如何删除导航栏的阴影
- 8. 快速定位导航栏标题
- 9. 快速导航栏的高度4
- 10. iPhone - 快速导航栏问题
- 11. Google即时状态栏和导航栏上的渐变/阴影
- 12. 如何从导航栏中删除阴影线?
- 13. 如何删除底部阴影的的导航栏在swift3
- 14. D3.js SVG阴影快速转换
- 15. 删除导航栏阴影iPhone 6/6plus上的颜色
- 16. 将阴影添加到导航栏的标题
- 17. 如何更改twitter-bootstrap导航栏的阴影框?
- 18. 滚动条上的Twitter bootstrap导航栏阴影
- 19. CSS文本 - 阴影导航问题
- 20. 添加阴影以滑出导航
- 21. 如何在用户开始滚动时向导航栏添加阴影?
- 22. 如何在反应导航标题下隐藏阴影?
- 23. 应用阴影
- 24. 快速导航到项目?
- 25. 使用工具栏进行快速导航有意义吗?
- 26. 使用快速操作时缺少导航栏
- 27. 那是导航栏阴性SEO
- 28. 在Android应用中删除通知栏阴影
- 29. angular2快速导航路线档用户
- 30. 快速导航到Couchbase中的文档
这个代码不工作,请编辑你的答案或删除它 –