更改UISearchBar button属性

时间:2014-11-06 12:18:24   收藏:0   阅读:227

//点击搜索框时触发

- (BOOL)searchBarShouldBeginEditing:(UISearchBar *)searchBar

{

    self.theSearchUserSearchBar.showsCancelButton = YES; //很关键

    

    UIView *topView = self.theSearchUserSearchBar.subviews[0];

    

    for (UIView *searchbuttons in topView.subviews)

    {

        if ([searchbuttons isKindOfClass:NSClassFromString(@"UINavigationButton")])//NSClassFromString(@"UINavigationButton")

        {

            UIButton *cancelButton = (UIButton*)searchbuttons;

            cancelButton.enabled = YES;

            [cancelButton setTitle:@"确定" forState:UIControlStateNormal];

            break;

        }

    }

 

 

    

    return YES;

}

 

所以,同理可以更改 UISearchBar上面的任意view。

 

原文:http://www.cnblogs.com/Camier-myNiuer/p/4078128.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!