#import "CustomTextField.h"
#define TEXTFIELD_PADDING 10.0
@implementation CustomTextField
//placehold
- (CGRect)textRectForBounds:(CGRect)bounds
{
return CGRectMake(bounds.origin.x + TEXTFIELD_PADDING, bounds.origin.y + TEXTFIELD_PADDING, bounds.size.width - TEXTFIELD_PADDING*2, bounds.size.height - TEXTFIELD_PADDING*2);
}
// text position
- (CGRect)editingRectForBounds:(CGRect)bounds
{
return [self textRectForBounds:bounds];
}
- (void)drawPlaceholderInRect:(CGRect)rect
{
[[UIColor blueColor] setFill];
//Fixed for iOS 5 and iOS 7 display issue
CGRect placeholderRect = CGRectMake(rect.origin.x, (rect.size.height- self.font.pointSize)/2, rect.size.width, self.font.pointSize);
[[self placeholder] drawInRect:placeholderRect withFont:self.font lineBreakMode:NSLineBreakByWordWrapping alignment:self.textAlignment];
}
@end
#define TEXTFIELD_PADDING 10.0
@implementation CustomTextField
//placehold
- (CGRect)textRectForBounds:(CGRect)bounds
{
return CGRectMake(bounds.origin.x + TEXTFIELD_PADDING, bounds.origin.y + TEXTFIELD_PADDING, bounds.size.width - TEXTFIELD_PADDING*2, bounds.size.height - TEXTFIELD_PADDING*2);
}
// text position
- (CGRect)editingRectForBounds:(CGRect)bounds
{
return [self textRectForBounds:bounds];
}
- (void)drawPlaceholderInRect:(CGRect)rect
{
[[UIColor blueColor] setFill];
//Fixed for iOS 5 and iOS 7 display issue
CGRect placeholderRect = CGRectMake(rect.origin.x, (rect.size.height- self.font.pointSize)/2, rect.size.width, self.font.pointSize);
[[self placeholder] drawInRect:placeholderRect withFont:self.font lineBreakMode:NSLineBreakByWordWrapping alignment:self.textAlignment];
}
@end