繁体   English   中英

UIView 圆边无底或顶边

[英]UIView rounded border without bottom or top side

我有 UIView ,我需要只画一个边框的部分视图,这就是我的设计看起来很像,我该怎么做?

设计

尝试这个

import UIKit

class ViewController: UIViewController {

    @IBOutlet weak var droppedView: UIView!
    
    override func viewDidLoad() {
        super.viewDidLoad()

        droppedView.clipsToBounds = true
        droppedView.layer.cornerRadius = 24   // 얼만큼 둥글게 할 것인지

        droppedView.layer.maskedCorners = [.layerMinXMinYCorner,
                                           .layerMaxXMinYCorner]
        droppedView.backgroundColor = .systemGray6
    }

}
@IBOutlet weak var shadowVw: UIView!

override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(animated)

        shadowVw.layer.cornerRadius = 24
        shadowVw.layer.maskedCorners = [.layerMinXMinYCorner,.layerMaxXMinYCorner]
        shadowVw.backgroundColor = .systemGray6
        shadowVw.layer.shadowColor = UIColor.lightGray.cgColor
        shadowVw.layer.shadowOpacity = 0.7
        shadowVw.layer.shadowOffset = CGSize(width: 0.0, height: -5.0)
        shadowVw.layer.shadowRadius = 5
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM