Skip to content

Instantly share code, notes, and snippets.

@Adnan1990
Created December 16, 2015 05:20
Show Gist options
  • Save Adnan1990/c16454bb7f0008413012 to your computer and use it in GitHub Desktop.
Save Adnan1990/c16454bb7f0008413012 to your computer and use it in GitHub Desktop.
Customizing TextField Placeholder
//
// CustomTextField.h
// LMKT
//
// Created by Adnan on 12/15/15.
//
//
#import <UIKit/UIKit.h>
@interface CustomTextField : UITextField
@end
//
// 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