Answers for "give corner radius to only one corner in view in xcode autolayout"

3

add top corner radius swift

extension UIView {
   func roundCorners(corners: UIRectCorner, radius: CGFloat) {
        let path = UIBezierPath(roundedRect: bounds, byRoundingCorners: corners, cornerRadii: CGSize(width: radius, height: radius))
        let mask = CAShapeLayer()
        mask.path = path.cgPath
        layer.mask = mask
    }
}
Posted by: Guest on July-10-2020
0

give corner radius to only one corner in view in xcode autolayout

import UIKit

class RoundedCornerView: UIView {

    // if cornerRadius variable is set/changed, change the corner radius of the UIView
    @IBInspectable var cornerRadius: CGFloat = 0 {
        didSet {
            layer.cornerRadius = cornerRadius
            layer.masksToBounds = cornerRadius > 0
        }
    }
	
}
Posted by: Guest on February-09-2021

Code answers related to "give corner radius to only one corner in view in xcode autolayout"

Browse Popular Code Answers by Language