美文网首页
searchBar的搜索图标靠左

searchBar的搜索图标靠左

作者: follow_er | 来源:发表于2016-08-04 12:25 被阅读186次

    # UISearchBar
    ## searchBar****的图标靠左

     SEL centerSelector = NSSelectorFromString([NSString stringWithFormat:@"%@%@", @"setCenter", @"Placeholder:"]);
        if ([seachBar respondsToSelector:centerSelector]){
            NSMethodSignature *signature = [[UISearchBar class] instanceMethodSignatureForSelector:centerSelector];
            NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:signature];
            [invocation setTarget:seachBar];
            [invocation setSelector:centerSelector];
            [invocation invoke];
        }
    
    

    serchBar改变cancel字体

     searchBar.showsCancelButton = YES;
        for(UIView *view in  [[[searchBar subviews] objectAtIndex:0] subviews]) {
            if([view isKindOfClass:[NSClassFromString(@"UINavigationButton") class]]) {
                UIButton * cancel =(UIButton *)view;
                [cancel setTitle:@"搜索" forState:UIControlStateNormal];
                cancel.titleLabel.font = [UIFont systemFontOfSize:14];
            }
        }
    

    相关文章

      网友评论

          本文标题:searchBar的搜索图标靠左

          本文链接:https://www.haomeiwen.com/subject/wlmcsttx.html