获取UISearchBar上的UITextField

获取UISearchBar上的UITextField并对其操作:

1     UITextField *searchField = [_searchBar valueForKey:@"_searchField"];
//获取只需要上面一句话
2 searchField.tag = 100; 3 searchField.textColor = fontBlackColor; 4 searchField.backgroundColor = Bg_Grey; 5 [searchField setLeftViewMode:UITextFieldViewModeNever]; 6 [searchField setRightViewMode:UITextFieldViewModeNever]; 7 [searchField setValue:fontGreyColor forKeyPath:@"_placeholderLabel.textColor"]; 8 [searchField becomeFirstResponder];

        [searchField setValue:[UIFont systemFontOfSize:12]forKeyPath:@"_placeholderLabel.font"];

        [searchField setBorderStyle:UITextBorderStyleNone];

        searchField.layer.borderWidth = 3.0f;

        searchField.layer.cornerRadius = 10.0f;

        searchField.layer.borderColor = [UIColor clearColor].CGColor;

        searchField.clearButtonMode=UITextFieldViewModeNever;

 

posted @ 2017-04-20 17:16  福泽小院  阅读(1428)  评论(0编辑  收藏  举报