Created
October 7, 2017 10:05
-
-
Save jimmythai/bab4e760727784620ff958c9c414f2cf to your computer and use it in GitHub Desktop.
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
import UIKit | |
extension UIView { | |
@IBInspectable var borderColor: UIColor? { | |
get { | |
return layer.borderColor.map { UIColor(cgColor: $0) } | |
} | |
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 | |
} | |
} | |
@IBInspectable var masksToBounds: Bool { | |
get { | |
return layer.masksToBounds | |
} | |
set { | |
layer.masksToBounds = newValue | |
} | |
} | |
@IBInspectable var shadowColor: UIColor? { | |
get { | |
return layer.shadowColor.map { UIColor(cgColor: $0) } | |
} | |
set { | |
layer.shadowColor = newValue?.cgColor | |
} | |
} | |
@IBInspectable var shadowOffset: CGSize { | |
get { | |
return layer.shadowOffset | |
} | |
set { | |
layer.shadowOffset = newValue | |
} | |
} | |
@IBInspectable var shadowRadius: CGFloat { | |
get { | |
return layer.shadowRadius | |
} | |
set { | |
layer.shadowRadius = newValue | |
} | |
} | |
@IBInspectable var shadowOpacity: Float { | |
get { | |
return layer.shadowOpacity | |
} | |
set { | |
layer.shadowOpacity = newValue | |
} | |
} | |
@IBInspectable var shouldRasterize: Bool { | |
get { | |
return layer.shouldRasterize | |
} | |
set { | |
layer.shouldRasterize = newValue | |
layer.rasterizationScale = UIScreen.main.scale | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment