Reputation: 39
I need to create a custom placeholder for textfield. I created the custom placeholder method but not getting how to call it in my class the code is:
(void)drawPlaceholderInRect:(CGRect)rect {
// Set colour and font size of placeholder text
[[UIColor redColor] setFill];
[[UIColor colorWithRed:255.0 green:0.0 blue:0.0 alpha:0.7] setFill];
[[self placeholder] drawInRect:rect withFont:[UIFont systemFontOfSize:5]];
}
in main .h created object for custom textfield class
CustomUITextFieldPlaceholder *txtName;
but not getting how to call for
**txt_userinput.placeholder=?**
and if have multiple textfield then how to call please help thanks in advance
Upvotes: 1
Views: 644
Reputation: 13364
Make your CustomUITextFieldPlaceholder
object and then you can call it -
CustomUITextFieldPlaceholder *obj = [[CustomUITextFieldPlaceholder alloc]init];
[obj drawPlaceholderInRect:CGRectMake(x,y,width,height)];
Upvotes: 1
Reputation: 1661
You can call the method this way (in your CustomUITextFieldPlaceholder class) :
[self drawPlaceholderInRect:aRect];
Or if you want to call from outside the CustomUITextFieldPlaceholder class :
[txtName drawPlaceholderInRect:aRect];
Upvotes: 1