How to call a extension file for a border of pitcure in swift

My code below is supposed to feature a customizable border for a photo taken. I originally had a border but it was not customizable. I saw this code online about a customizable border in a extension file (CALAYER). Its obviously to me I have to call the CALYAER function in my class file (x1ViewController) for the border to appear I just don’t know how to do it.

import UIKit

extension CALayer {
func addBorder(edge: UIRectEdge, color: UIColor, thickness: CGFloat) {

let border = CALayer();

switch edge {
    border.frame = CGRect(x: 0, y: 0, width: self.frame.width, height: thickness)
case UIRectEdge.bottom:
    border.frame = CGRect(x:0, y:self.frame.height - thickness, width:self.frame.width, height:thickness)
case UIRectEdge.left:
    border.frame = CGRect(x:0, y:0, width: thickness, height: self.frame.height)
case UIRectEdge.right:
    border.frame = CGRect(x:self.frame.width - thickness, y: 0, width: thickness, height:self.frame.height)

border.backgroundColor = color.cgColor;




class x1ViewController: UIViewController, UIImagePickerControllerDelegate, UINavigationControllerDelegate, UITextFieldDelegate {

@IBOutlet weak var imageDisplay: UIImageView!
var screenView: UIImageView!

@IBAction func camera(_ sender: AnyObject) {
if UIImagePickerController.isSourceTypeAvailable({
let imagePicker = UIImagePickerController()
imagePicker.delegate = self

   // imageDisplay.layer.borderColor = UIColor(red: 0, green: 1.0, blue: 0, alpha: 1).cgColor
    //imageDisplay.layer.cornerRadius = 1
   // imageDisplay.contentMode = .scaleAspectFit
   // imageDisplay.layer.borderWidth = 1

    imagePicker.sourceType =;
    imagePicker.allowsEditing = false
    self.present(imagePicker, animated: true, completion: nil)}}

func imagePickerController(_ picker: UIImagePickerController, didFinishPickingImage image: UIImage!, editingInfo: [NSObject: AnyObject]!){
imageDisplay.image = image
self.dismiss(animated: true, completion: nil);
screenView = UIImageView()

screenView.frame = CGRect(x:0, y: 0, width: self.view.frame.width, height: self.view.frame.height)

let text = "#HAPPY"
let label = UILabel(frame: CGRect(x: 125, y: 700, width: self.view.frame.width, height: 300))
label.font = UIFont(name: label.font.fontName, size: 122)

label.textColor =
label.alpha = 1.0
label.text = text


self.view.drawHierarchy(in: self.view.frame, afterScreenUpdates: true)

@IBAction func save(_ sender: AnyObject) {

let alert = UIAlertController(title: "Image Saved", message: "Image is in photo gallery", preferredStyle: .alert)
let okay = UIAlertAction(title: "OK", style: .default, handler: nil)
present(alert, animated: true, completion: nil)

let photo = UIGraphicsGetImageFromCurrentImageContext()
UIImageWriteToSavedPhotosAlbum(photo!, nil, nil, nil)