UIsearchBar怎么将canal改为取消,怎么点击取消按钮将键盘和searchbar复原

 self.mySearchBar.showsCancelButton = YES;

    for(UIView *view in  [[[self.mySearchBar subviews] objectAtIndex:0] subviews]) {

        if([view isKindOfClass:[NSClassFromString(@"UINavigationButton") class]]) {

            UIButton * cancel =(UIButton *)view;

            [cancel setTitle:@"取消" forState:UIControlStateNormal];

        }

    }

//searchBar取消按钮的代理方法

-(void)searchBarCancelButtonClicked:(UISearchBar *)searchBar

{

    [self.mySearchBar resignFirstResponder ];

}


你可能感兴趣的:(UIsearchBar怎么将canal改为取消,怎么点击取消按钮将键盘和searchbar复原)