how to round only one corner in swift code example
Example 1: 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
}
}
Example 2: round down swift
let number = 0.1
// Use ceil to remove the fractional part and round up.
let result = ceil(number)
let number1 = 1.1
// Use floor to remove the fractional part and round down.
let floor1 = floor(number1)