透明动画
只需设置NavigationBar的背景图片为一张空图片便可spa
//设置导航栏透明 self.navigationController?.navigationBar.setBackgroundImage(UIImage(), forBarMetrics: UIBarMetrics.Default) self.navigationController?.navigationBar.shadowImage = UIImage()
在NavigationBar下插入一个view,执行动画改变这个view的透明度便可。code
let frame = self.navigationController?.navigationBar.frame let alphaView = UIView(frame: CGRect(x: 0, y: -20, width: frame!.size.width, height: frame!.size.height+20)) alphaView.backgroundColor = UIColor.blueColor() alphaView.userInteractionEnabled = false self.navigationController?.navigationBar.insertSubview(alphaView, atIndex: 0)