UITextField の拡張機能を作成しました。そして、UITextView にも同じ拡張機能が必要です。この拡張機能を他のすべてのビューで使用できるようにするにはどうすればよいですか?
私の延長コード:
extension UITextField {
func addTopBorderWithColor(color: UIColor, height: CGFloat) {
let border = CALayer()
border.backgroundColor = color.CGColor
border.frame = CGRectMake(0, 0, self.frame.size.width, height)
self.layer.addSublayer(border)
}
func addRightBorderWithColor(color: UIColor, height: CGFloat) {
let border = CALayer()
border.backgroundColor = color.CGColor
border.frame = CGRectMake(self.frame.size.width - height, 0, height, self.frame.size.height)
self.layer.addSublayer(border)
}
func addBottomBorderWithColor(color: UIColor, height: CGFloat) {
let border = CALayer()
border.backgroundColor = color.CGColor
border.frame = CGRectMake(0, self.frame.size.height - height, self.frame.size.width, height)
self.layer.addSublayer(border)
}
func addLeftBorderWithColor(color: UIColor, height: CGFloat) {
let border = CALayer()
border.backgroundColor = color.CGColor
border.frame = CGRectMake(0, 0, height, self.frame.size.height)
self.layer.addSublayer(border)
}
}