Swift 3.0 高仿微信
在navigationBar底部添加一个添加了渐变层的view
let blurBackView = UIView()
blurBackView.frame = CGRect(x: 0, y: -20, width: kScreenW, height: 64)
let gradintLayer = CAGradientLayer()
gradintLayer.frame = CGRect(x: 0, y: 0, width: kScreenW, height: 64)
gradintLayer.colors = [
UIColor.hexInt(0x040012).withAlphaComponent(0.76).cgColor,
UIColor.hexInt(0x040012).withAlphaComponent(0.28).cgColor
]
gradintLayer.startPoint = CGPoint(x: 0, y: 0)
gradintLayer.endPoint = CGPoint(x: 0, y: 1.0)
blurBackView.layer.addSublayer(gradintLayer)
blurBackView.isUserInteractionEnabled = false
blurBackView.alpha = 0.5
// 设置导航栏样式
navigationBar.barStyle = .black
navigationBar.insertSubview(blurBackView, at: 0)
遇到的问题总结了一下,可以参考下以下总结的文章
《iOS - Swift UICollectionView横向分页滚动,cell左右排版》
《iOS - Swift UICollectionView横向分页的问题》
《iOS - Swift UITableView的scrollToRow的"坑"》
《iOS - Swift UIButton中ImageView的animationImages动画执行完毕后,图标变暗》