Add UITextField to the title view of the navigation item

How do you add a text box to the title view of the navigation item and is it sized correctly?

It works fine if I do this using a search bar like this, but I don't know how to get a text box for the size itself just like a search bar.

myViewController.navigationItem.titleView = [UISearchBar new]; 
+6
source share
1 answer

As my comment suggested, try the following, which seems to me after you.

 UITextField *textField = [[UITextField alloc]initWithFrame:CGRectMake(0, 0, self.navigationController.navigationBar.frame.size.width, 21.0)]; self.navigationItem.titleView = textField; [textField becomeFirstResponder]; 
+21
source

Source: https://habr.com/ru/post/972897/


All Articles