Last active
October 10, 2020 16:54
-
-
Save Slowhand0309/0d653b79dae0d4908e978fc18ef4ae34 to your computer and use it in GitHub Desktop.
[Padding UITextField] Add padding to UITextField #iOS
This file contains hidden or 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 | |
@IBDesignable class UIPaddingTextField: UITextField { | |
// MARK: Properties | |
@IBInspectable var padding: CGPoint = CGPoint(x: 8.0, y: 0.0) | |
// MARK: Internal Methods | |
override func textRect(forBounds bounds: CGRect) -> CGRect { | |
return bounds.insetBy(dx: self.padding.x, dy: self.padding.y) | |
} | |
override func editingRect(forBounds bounds: CGRect) -> CGRect { | |
return bounds.insetBy(dx: self.padding.x, dy: self.padding.y) | |
} | |
override func placeholderRect(forBounds bounds: CGRect) -> CGRect { | |
return bounds.insetBy(dx: self.padding.x, dy: self.padding.y) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment