1. 程式人生 > >隱藏UISearchBar中的刪除按鈕

隱藏UISearchBar中的刪除按鈕

按鈕 views font textfield skin searchbar search clas arch

UISearchBar *searchBar;

for (UIView *subview in [searchBar.subviews firstObject].subviews) {

  if ([subview isKindOfClass:[UITextField class]]) {

    UITextField *searchField = (UITextField *)subview;

    searchField.clearButtonMode = UITextFieldViewModeNever;

    break;

  }

}

隱藏UISearchBar中的刪除按鈕