You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
// // UIViewExtension.swift // GMERemittance // // Created by Fm-user on 12/23/17. // Copyright © 2017 Gobal Money Express Co. Ltd. All rights reserved. //
import Foundation import UIKit
extension UIView { func roundCorners(_ corners: UIRectCorner, radius: CGFloat, borderColor: UIColor?, borderWidth: CGFloat?) { let path = UIBezierPath(roundedRect: self.bounds, byRoundingCorners: corners, cornerRadii: CGSize(width: radius, height: radius)) let mask = CAShapeLayer() mask.frame = self.bounds mask.path = path.cgPath self.layer.mask = mask if borderWidth != nil { addBorder(mask, borderWidth: borderWidth!, borderColor: borderColor!) } } private func addBorder(_ mask: CAShapeLayer, borderWidth: CGFloat, borderColor: UIColor) { let borderLayer = CAShapeLayer() borderLayer.path = mask.path borderLayer.fillColor = UIColor.clear.cgColor borderLayer.strokeColor = borderColor.cgColor borderLayer.lineWidth = borderWidth borderLayer.frame = bounds layer.addSublayer(borderLayer) } func rounded() { self.layer.cornerRadius = self.frame.height / 2 }
}
|