From e33aa9d5ace9fef4997198bae9a3e39c73e5a762 Mon Sep 17 00:00:00 2001 From: Oleksandr Bezpalchuk Date: Mon, 14 Sep 2015 16:15:41 +0300 Subject: [PATCH] Added ability to change position of placeholder and text in textfield --- CHDropDownTextField/CHDropDownTextField.h | 10 ++++++++++ CHDropDownTextField/CHDropDownTextField.m | 10 ++++++++++ 2 files changed, 20 insertions(+) diff --git a/CHDropDownTextField/CHDropDownTextField.h b/CHDropDownTextField/CHDropDownTextField.h index 6c592ce..cbf9ca9 100644 --- a/CHDropDownTextField/CHDropDownTextField.h +++ b/CHDropDownTextField/CHDropDownTextField.h @@ -62,6 +62,16 @@ */ @property (nonatomic, assign) BOOL canPaste; +/** + Indicates the textfields text inset by Y. Defaults to 0. + */ +@property (nonatomic, assign) CGFloat dY; + +/** + Indicates the textfields text inset by X. Defaults to 0. + */ +@property (nonatomic, assign) CGFloat dX; + /** Indicates the drop-down's number of visible rows at a time. Defaults to 0. */ diff --git a/CHDropDownTextField/CHDropDownTextField.m b/CHDropDownTextField/CHDropDownTextField.m index 453eaf0..e4cb3af 100644 --- a/CHDropDownTextField/CHDropDownTextField.m +++ b/CHDropDownTextField/CHDropDownTextField.m @@ -204,6 +204,16 @@ - (BOOL)canPerformAction:(SEL)action withSender:(id)sender { return [super canPerformAction:action withSender:sender]; } +// placeholder position +- (CGRect)textRectForBounds:(CGRect)bounds { + return CGRectInset(bounds, _dX, _dY); +} + +// text position +- (CGRect)editingRectForBounds:(CGRect)bounds { + return CGRectInset(bounds, _dX, _dY); +} + #pragma mark - UITableViewDataSource - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {