Created
June 9, 2017 18:23
-
-
Save dgyesbreghs/0447cac817ce6759092210551a96cb0f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// UIView+RoundCorners.swift | |
// PullableView | |
// | |
// Created by Dylan Gyesbreghs on 09/06/2017. | |
// Copyright © 2017 Dylan Gyesbreghs. All rights reserved. | |
// | |
import UIKit | |
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 | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment