'UITextField with trailing placeholder text

I am making an UITextField input where user can enter an subdomain for their site. What i want to accomplish is, that i can show the whole url in the input but only the subdomain part is editable. Any tips how to accomplish that?

Update

The right solutions was to use UILabel in UITextField's rightView and calculating the position in rightViewRectForBounds.



Solution 1:[1]

First, UITextField has a property named AttributePlaceholder, it allows to display different color of placeholder.

And then when didBeginEditing:, fill the textfield with url, without the subdomain. Remember the count of characters.

When user editing, called on the method:

- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string;

Return NO when textfield.text.count <= characters.count

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Klein Mioke