Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- // UIView+OneSideBorder.swift
- // Rocket.Chat
- //
- // Created by Msheikh on 7/8/18.
- // Copyright © 2018 Rocket.Chat. All rights reserved.
- //
- import Foundation
- 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: frame.minX, y: frame.minY, width: thickness, height: frame.height); break
- case .right: border.frame = CGRect(x: frame.maxX, y: frame.minY, width: thickness, height: frame.height); break
- case .top: border.frame = CGRect(x: frame.minX, y: frame.minY, width: frame.width, height: thickness); break
- case .bottom: border.frame = CGRect(x: frame.minX, y: frame.maxY, width: frame.width, height: thickness); break
- }
- layer.addSublayer(border)
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement