UITableView content overlaps Status Bar when UISearchBar is active

后端 未结 8 622
北海茫月
北海茫月 2021-02-05 02:17

I have a UITableViewController with a UISearchBar and UISearchDisplayController. That exists inside a Container View in a UIViewController which is in a UINavigationController.

8条回答
  •  孤街浪徒
    2021-02-05 03:00

    I have UISearchBar and UISearchDisplayController.

    In viewdidload:

    self.edgesForExtendedLayout = UIRectEdgeNone;
    [searchDisplayController.searchBar setBackgroundImage:[self imageWithColor:ETSBaseColor] forBarPosition:0 barMetrics:UIBarMetricsDefault];
    

    method that obtain image from UIColor:

    - (UIImage *)imageWithColor:(UIColor *)color
    {
        CGRect rect = CGRectMake(0.0f, 0.0f, 1.0f, 1.0f);
        UIGraphicsBeginImageContext(rect.size);
        CGContextRef context = UIGraphicsGetCurrentContext();
    
        CGContextSetFillColorWithColor(context, [color CGColor]);
        CGContextFillRect(context, rect);
    
        UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
        UIGraphicsEndImageContext();
    
        return image;
    }
    

提交回复
热议问题