Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Mobile-Applications UITextField Background Image

Have Programming Question? Ask it here!
 
 
 


Java Coder
UITextField Background Image
2 Answer(s)      3 years and 8 months ago
Posted in : MobileApplications


How can i set a background image on UITextField. I have placed that UITextField on UIToolBar.


Advertisement
View Answers

January 12, 2011 at 12:33 PM


Code to Set a Background Image on UITextField

 - (void)viewDidLoad {
    [super viewDidLoad];

    myTextField.borderStyle = UITextBorderStyleNone;
    myTextField.background = [UIImage imageNamed:@"search.png"];
}


January 12, 2011 at 12:38 PM


We can also set the uitextfield leftview or uitextfield rightView. This method is required when we wanted to add a small image on text field as a right or left view. Find the code below.. on how to set the uitextfield leftview image..

- (void)viewDidLoad {
    [super viewDidLoad];

    UIImageView *myView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"search.png"]];
    [myTextField  setRightView:myView];
    [myTextField  setRightViewMode:UITextFieldViewModeAlways];
    [myView release];
}


Related Tutorials/Questions & Answers:
 

 

 

DMCA.com