UISearchDisplayDelegate how to remove this opaque view?

前端 未结 4 657
醉话见心
醉话见心 2021-01-16 16:41

how can i programmatically show/hide this opaque view from UISearchDisplayController?

\"enter

4条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-16 17:02

    The other answers where not working for me. This one works for me on iOS7 and iOS8.

    for( UIView *subview in self.view.subviews ) {
        if([subview  isMemberOfClass:[UIControl class]] ||
           ([[[subview  class] description] isEqualToString:@"UISearchDisplayControllerContainerView"])) {
            for(UIView *subView2 in subview.subviews)
            {
                for(UIView *subView3 in subView2.subviews)
                {
                    if (subView3.alpha < 1) {
                        subView3.hidden = YES;
                    }
                }
            }
        }
    }
    

    If you don't need support for iOS7 please don't use the searchDisplayController anymore because its deprecated. For iOS8 use the UISearchController and the dimsBackgroundDuringPresentation Property

    Ref: https://developer.apple.com/library/prerelease/ios/documentation/UIKit/Reference/UISearchController/index.html#//apple_ref/occ/instp/UISearchController/dimsBackgroundDuringPresentation

提交回复
热议问题