1. UITextField *textField = [[UITextField alloc] init];
  2. textField.frame = CGRectMake(38.0f, 0.0f, self.view.frame.size.width - 38.0f, 40.0f);
  3. textField.text = @"Hello";
  4. textField.background = [[UIImage imageNamed: @"field.png"] stretchableImageWithLeftCapWidth:12 topCapHeight:19];
  5. textField.backgroundColor = [UIColor whiteColor];
  6. textField.userInteractionEnabled = YES;
  7.  
  8. [bar addSubview: textField];
  9.  
  10. bar.userInteractionEnabled = TRUE;