resize UISearchDisplayController dimmed black overlay

后端 未结 3 877
梦毁少年i
梦毁少年i 2021-02-04 17:16

anybody know how to resize the dimmed black overly, once you clicked the search bar ?

i having problem when i clicked cancelled the tableview will expend then animated t

3条回答
  •  日久生厌
    2021-02-04 17:39

    I combined several answers in order to move the dimmed overlay frame.

    1: override UISearchDisplayController class

    @interface MySearchController : UISearchDisplayController
    

    2: override setActive function

    - (void)setActive:(BOOL)visible animated:(BOOL)animated
    {
    [super setActive: visible animated: animated];
    
    //move the dimming part down
    for (UIView *subview in self.searchContentsController.view.subviews) {
        //NSLog(@"%@", NSStringFromClass([subview class]));
        if ([subview isKindOfClass:NSClassFromString(@"UISearchDisplayControllerContainerView")])
        {
            CGRect frame = subview.frame;
            frame.origin.y += 10;
            subview.frame = frame;
        }
    }
    
    }
    

    3: change the xib/storyboard Search Display Controller from UISearchDisplayController to MySearchController

提交回复
热议问题