0

In my iOS project, i added an image to the right of text field. It leaned on borders at all. enter image description here

Then i searched and find this topic and used TTillage's solution. It became better, but still leaned on top and bottom borders. enter image description here

Finally i changed the frame of my image, however pulling inside from right border was not working at this point. My final view is: enter image description here

I want this little image to be a bit away from borders and not stretched (if i do second version with third, it gets stretched). Is there a way for this? My code:

 myImage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"myImage.png"]]; myImage.frame = CGRectMake(30.0, 0.0, self.textField.frame.size.height-5.0, self.textField.frame.size.height-5.0); //myImage.contentMode = UIViewContentModeCenter; self.textField.rightViewMode = UITextFieldViewModeUnlessEditing; self.textField.rightView = myImage; 

Thank you.

4
  • what happens if u uncomment the 'contentMode' line ?? Commented Nov 4, 2015 at 7:07
  • In last version this content mode makes the frame alteration uneffective. Nothing changes. If i comment this line, third picture appears. Commented Nov 4, 2015 at 7:12
  • ok. Can u try the answer. see if it helps Commented Nov 4, 2015 at 7:16
  • Remove text field border, wrap it in UIView, add margins to it. Commented Nov 4, 2015 at 7:43

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.