Created
December 16, 2015 05:20
-
-
Save Adnan1990/c16454bb7f0008413012 to your computer and use it in GitHub Desktop.
Customizing TextField Placeholder
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
// | |
// CustomTextField.h | |
// LMKT | |
// | |
// Created by Adnan on 12/15/15. | |
// | |
// | |
#import <UIKit/UIKit.h> | |
@interface CustomTextField : UITextField | |
@end |
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
// | |
// CustomTextField.m | |
// LMKT | |
// | |
// Created by Adnan on 12/15/15. | |
// | |
// | |
#import "CustomTextField.h" | |
@implementation CustomTextField | |
- (void)drawPlaceholderInRect:(CGRect)rect { | |
BOOL currentdevice=[[UIDevice currentDevice].model hasPrefix:@"iPhone"]; | |
if(currentdevice){ | |
NSDictionary *attrDictionary = @{ | |
NSForegroundColorAttributeName: [UIColor redColor], | |
NSFontAttributeName : [UIFont fontWithName:@"OpenSans" size:15.0] | |
}; | |
[[self placeholder] drawInRect:rect withAttributes:attrDictionary]; | |
} | |
else{ | |
NSDictionary *attrDictionary = @{ | |
NSForegroundColorAttributeName: [UIColor redColor], | |
NSFontAttributeName : [UIFont fontWithName:@"OpenSans" size:20.0] | |
}; | |
[[self placeholder] drawInRect:rect withAttributes:attrDictionary]; | |
} | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment