This file contains hidden or 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
// | |
// WebViewExampleViewController.swift | |
// | |
// Created by Felix Mau on 06.01.18. | |
// Copyright © 2018 Felix Mau. All rights reserved. | |
// | |
import UIKit | |
import WebKit |
This file contains hidden or 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
func imageByAddingBorder(width: CGFloat, color: UIColor) -> UIImage? { | |
UIGraphicsBeginImageContext(self.size) | |
let imageRect = CGRect(x: 0, y: 0, width: self.size.width, height: self.size.height) | |
self.draw(in: imageRect) | |
let context = UIGraphicsGetCurrentContext() | |
let borderRect = imageRect.insetBy(dx: width / 2, dy: width / 2) | |
context?.setStrokeColor(color.cgColor) |