I am trying to build a textfield with a custom prefix (think of the textfield for inputting a phone number and the prefix being the international dialling code). I would like the textfield to behave very much like a normal textfield and the prefix area to be not selectable. Moreover, I would like the prefix to move and stay close to the text as the phone number is being inputted. At the start, the prefix should just be drawn in from of the placeholder text.
To achieve this, I am subclassing UITextField and overriding the drawTextInRect and drawPlaceHolderTextInRect to draw a custom prefix in front of the text to be drawn. This works like a charm when the textfield is empty (drawPlaceHolderTextInRect gets called) or when the textfield is not in editing mode (drawTextInRect gets called). However, when the textfield is in editing mode and not empty, neither of those methods get called. Is there any other method I can override to provide custom drawing while the user is inputting the phone number in the textfield?