Skip to content

Instantly share code, notes, and snippets.

@edenman
edenman / CALayerExtension.swift
Last active October 6, 2016 02:24
Swift (2.3) CALayer extension to only round _some_ corners
extension CALayer {
func roundCorners(corners: UIRectCorner, radius: CGFloat) {
let maskPath = UIBezierPath(roundedRect: bounds,
byRoundingCorners: corners,
cornerRadii: CGSize(width: radius, height: radius))
let shape = CAShapeLayer()
shape.path = maskPath.CGPath
mask = shape
}