Last active
February 9, 2019 12:56
-
-
Save GonzalezAnguita/c5bc310145a1f74ee61e026852cc8f4f to your computer and use it in GitHub Desktop.
Border and corner extension for UIView - Swift 3
This file contains 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
// | |
// Credits to: | |
// https://gist.github.com/feighter09/c502d7550e4cdb82d526157f5cf8bef1 | |
// http://nshipster.com/ibinspectable-ibdesignable/ | |
// | |
// Created by José Tomás González on 23-04-17. | |
// Copyright © 2017 Swipe. All rights reserved. | |
// | |
import Foundation | |
import UIKit | |
extension UIView { | |
@IBInspectable var borderColor: UIColor? { | |
get { | |
return layer.borderColor.map(UIColor.init) | |
} | |
set { | |
layer.borderColor = newValue?.cgColor | |
} | |
} | |
@IBInspectable var borderWidth: CGFloat { | |
get { | |
return layer.borderWidth | |
} | |
set { | |
layer.borderWidth = newValue | |
} | |
} | |
@IBInspectable var cornerRadius: CGFloat { | |
get { | |
return layer.cornerRadius | |
} | |
set { | |
layer.cornerRadius = newValue | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
README
This code adds the possibility of modifying an interface border color, width and corner radius through the Interface Builder’s inspector panel of any element that inherits from UIView.
Credits to NSHipster