美文网首页
【转】UISearchController change 

【转】UISearchController change 

作者: 兔兔瑾 | 来源:发表于2016-08-22 17:35 被阅读41次

    http://stackoverflow.com/questions/28642807/uisearchcontroller-change-cancel-button-title

    swift version:

    for view:UIView in (searchView?.subviews)!
    {
    for subView:UIView in (view.subviews)
    {
    if ( subView is UIButton )
    {
    let cancelBut = subView as! UIButton

                //do stuff with cancelButton here
            }
        }
    }
    

    You can change the "Cancel" Button in search bar using this-

    for (UIView *view in searchBar.subviews)
    {
    for (id subview in view.subviews)
    {
    if ( [subview isKindOfClass:[UIButton class]] )
    {
    [subview setEnabled:YES];
    UIButton cancelButton = (UIButton)subview;
    [cancelButton setTitle:@"hi" forState:UIControlStateNormal];

            NSLog(@"enableCancelButton");
            return;
        }
    }
    

    }

    相关文章

      网友评论

          本文标题:【转】UISearchController change 

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