| 1234567891011121314151617181920212223242526 |
- // LoopFollow
- // UIViewExtension.swift
- // Created by Jose Paredes.
- import Foundation
- import UIKit
- extension UIView {
- enum ViewSide {
- case Left, Right, Top, Bottom
- }
- func addBorder(toSide side: ViewSide, withColor color: CGColor, andThickness thickness: CGFloat) {
- let border = CALayer()
- border.backgroundColor = color
- switch side {
- case .Left: border.frame = CGRect(x: 0, y: 0, width: thickness, height: frame.height)
- case .Right: border.frame = CGRect(x: frame.width - thickness, y: 0, width: thickness, height: frame.height)
- case .Top: border.frame = CGRect(x: 0, y: 0, width: frame.width, height: thickness)
- case .Bottom: border.frame = CGRect(x: 0, y: frame.height - thickness, width: frame.width, height: thickness)
- }
- layer.addSublayer(border)
- }
- }
|