View设置下边阴影

//navigationBar可以直接设置阴影,有shadowImage属性

imageViewAddShadow(imageView: (self.navigationController?.navigationBar)!)

commView?.shadowView.layer.masksToBounds = false   //commView?.shadowView 需要有背景图片,可以使用白色图片

        commView?.shadowView.layer.shadowColor = UIColor.black.withAlphaComponent(1).cgColor

        commView?.shadowView.layer.shadowOpacity = 0.5

        commView?.shadowView.layer.shadowRadius = 2

        commView?.shadowView.layer.shadowOffset = CGSize.zero

        let shadowRect = CGRect.init(x: 0, y:  (commView?.shadowView.bounds.size.height)!-4, width: (commView?.shadowView.bounds.size.width)!, height: 8) //下边线的上下两边都有一个4的阴影,图片可以遮住上边的阴影

        let path = UIBezierPath.init(rect: shadowRect)

        commView?.shadowView.layer.shadowPath = path.cgPath

猜你喜欢

转载自blog.csdn.net/weixin_39872861/article/details/81208810
今日推荐