菜鸟教程小白 发表于 2022-12-11 20:27:00

ios - 将阴影和角添加到 UIView 除了底部


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

<p> <a href="/image/tilpx.png" rel="noreferrer noopener nofollow"><img src="/image/tilpx.png" alt="enter image description here"/></a> </p></p>
                                    <br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
                                            <p><pre><code>@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
    }
</code></pre></p>
                                   
                                                <p style="font-size: 20px;">关于ios - 将阴影和角添加到 UIView 除了底部,我们在Stack Overflow上找到一个类似的问题:
                                                        <a href="https://stackoverflow.com/questions/51783502/" rel="noreferrer noopener nofollow" style="color: red;">
                                                                https://stackoverflow.com/questions/51783502/
                                                        </a>
                                                </p>
                                       
页: [1]
查看完整版本: ios - 将阴影和角添加到 UIView 除了底部