Skip to content

Instantly share code, notes, and snippets.

@fozoglu
Created January 24, 2017 11:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fozoglu/ecb99d82c76d0d381c2ae3f8d51ebc7a to your computer and use it in GitHub Desktop.
Save fozoglu/ecb99d82c76d0d381c2ae3f8d51ebc7a to your computer and use it in GitHub Desktop.
Custom TextField
import UIKit
@IBDesignable class DesignableTextField: UITextField {
@IBInspectable var borderWidth: CGFloat = 0.0{
didSet{
self.layer.borderWidth = borderWidth
}
}
@IBInspectable var borderColor: UIColor = UIColor.clear{
didSet{
self.layer.borderColor = borderColor.cgColor
}
}
@IBInspectable var cornerRadius: CGFloat = 0 {
didSet{
self.layer.cornerRadius = cornerRadius
}
}
@IBInspectable var placeHolderColor: UIColor = UIColor.clear{
didSet{
if let placeholder = self.placeholder {
let attributes = [NSForegroundColorAttributeName: placeHolderColor]
attributedPlaceholder = NSAttributedString(string: placeholder, attributes: attributes)
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment