skip to Main Content

I have UIView which I need to draw a border only partial part view, this is how my design look alike, how do i make it ?

expected

2

Answers


  1. Try this

    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
        }
    
    }
    
    Login or Signup to reply.
  2. @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
    }
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search