OGeek|极客世界-中国程序员成长平台

标题: ios - 将阴影和角添加到 UIView 除了底部 [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-11 20:27
标题: ios - 将阴影和角添加到 UIView 除了底部

我想在左上角和右上角添加圆角,并在其周围添加阴影,底部除外。底部不应有阴影。 我能够根据需要实现圆角。但不是影子。我需要一个同时实现两者的代码。在下图中,查看诊断 View 。它的左上角和右上角是圆形的,周围有阴影。

enter image description here



Best Answer-推荐答案


  @IBOutlet var btnActive : UIButton!

    override func viewDidLoad() {
        super.viewDidLoad()


      //  btnActive.backgroundColor = UIColor(red: 171, green: 178, blue: 186, alpha: 1.0)
        // Shadow and Radius
        btnActive.layer.shadowColor = UIColor(red: 255, green: 255, blue: 255, alpha: 1).cgColor
        btnActive.layer.shadowOffset = CGSize(width: 0.0, height: 2.0)
        btnActive.layer.shadowOpacity = 2.0
        btnActive.layer.shadowRadius = 5.0
        btnActive.layer.masksToBounds = false
        btnActive.layer.cornerRadius = 4.0
    }

关于ios - 将阴影和角添加到 UIView 除了底部,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51783502/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://ogeek.cn/) Powered by Discuz! X3.4