I did it this way. I know that you got to the answer uptil now but still it will help someone else, so it can be done as follows:
-(void)viewWillAppear:(BOOL)animated { imgVw =[[UIImageView alloc]initWithFrame:CGRectMake(68, 7, 180, 28)]; [imgVw setImage:[UIImage imageNamed:@"textfieldBackground.png"]]; [self.navigationController.navigationBar addSubview:imgVw]; textfieldTxt = [[UITextField alloc]initWithFrame:CGRectMake(78, 11, 170, 25)]; textfieldTxt.backgroundColor = [UIColor clearColor]; [textfieldTxt setAutocorrectionType:UITextAutocorrectionTypeNo]; textfieldTxt.delegate = self; [self.navigationController.navigationBar addSubview:textfieldTxt]; }
please do not forget to remove from the supervisor when viewdidunload
- (void)viewDidUnload { [super viewDidUnload]; [textfieldTxt removeFromSuperview]; [imgVw removeFromSuperview]; }
thanks
source share