Reputation: 2525
I want to add mandatory field mark in textfield placeholder text like below image please suggest me i am totally confused how to do it
Upvotes: 0
Views: 276
Reputation: 3928
Try with this.....
[tfSubject setValue:[UIColor colorWithRed:249.0/255.0 green:204.0/255.0 blue:88.0/255.0 alpha:1.0] forKeyPath:@"_placeholderLabel.textColor"];
Upvotes: 0
Reputation: 46533
You can use :
NSMutableAttributedString *attriButedString = [[NSMutableAttributedString alloc]initWithString:@"Mandatory*"];
[attriButedString addAttribute:NSForegroundColorAttributeName
value:[NSColor lightGrayColor]
range:NSMakeRange(0, 9)];
[attriButedString addAttribute:NSForegroundColorAttributeName
value:[NSColor redColor]
range:NSMakeRange(9, 1)];
[[self.textField cell] setPlaceholderAttributedString:attriButedString];
This will look like as:
Note: Instead of hard-coded range you can calculate according to your stringlength.
Upvotes: 6
Reputation: 3663
If you are creating TextField from xib click on text field and go to attribute inspecter and fill your placeholder name in placeholder text feild
Upvotes: 0