Big picture: This is what I am trying to accomplish. Send a text message to someone. The UI/UX should look something similar to this:

So, currently, I am using UITableView with 3 cells. The first two (for “To:” and “From:”) are 44px high. I put a UITextField inside the “contentView” of a UITableViewCell. Everything is good. I can get the user to edit the content of the cell.
Now, I am using the leftView property to display a UILabel with text “To:”. It works but the “To” label is always on the very left of the UITextField (shown in img below):

So, according to the SDK documentation. The left view mode is dictated by this method:
leftViewRectForBounds:
According to the discussion:
You should not call this method
directly. If you want to place the
left overlay view in a different
location, you can override this method
and return the new rectangle.
So, I tried overriding without much success. If anyone have any code snippets, I would greatly appreciate it. In the bottom picture, I set the “From” to be ” From” which is “hacking” it a little bit but I would like to do it correctly. This is what I have tried:
// override leftViewRectForBounds method:
- (CGRect)leftViewRectForBounds:(CGRect)bounds{
CGRect leftBounds = CGRectMake(bounds.origin.x + 30, 0, 45, 44);
return leftBounds;
}
and small variants of it and it doesn’t seem to work so any help is appreciated. Thanks!!!
you could have your class something like below
Use MyTextField instead of UITextField.