kiran
kiran

Reputation: 4409

Corner radius to superview subview UIView not shown

Added UIView of (50 height) to superview i.e., UIView a 50 % hold inside remaining outside to superview.

After adding corner radius to superview the below half of bottomView is not shown.

extension UIView{

    func roundCorners(_ corners: UIRectCorner, radius: CGFloat) {
        let path = UIBezierPath(roundedRect: self.bounds, byRoundingCorners: corners, cornerRadii: CGSize(width: radius, height: radius))
        let mask = CAShapeLayer()
        mask.path = path.cgPath
        self.layer.mask = mask
    }
}

override func awakeFromNib() {
    super.awakeFromNib()
    // Initialization code
    bg_view.roundCorners([.bottomLeft, .bottomRight], radius: 20). // MainView
    SearchView.bringSubviewToFront(bg_View)
}

Here is storyboard image

d

Upvotes: 0

Views: 327

Answers (1)

Feridun Erbaş
Feridun Erbaş

Reputation: 654

You should move green view out of your background view which clips its bounds since your are setting cornerRadius. Your green view can have centerY constraint equal to your backgroundViews bottom. In order to achieve this, you can first define vertical spacing between them and then edit that constraints first item to centerY

View hierarchy

Upvotes: 0

Related Questions