Ios 激活时删除UISearchController搜索栏背景

Ios 激活时删除UISearchController搜索栏背景,ios,swift,uisearchbar,uisearchcontroller,Ios,Swift,Uisearchbar,Uisearchcontroller,我想在Swift中自定义UISearchController的外观 现在,我更改了占位符和搜索文本的字体和颜色,并更改了明文按钮图像 我需要删除搜索栏的背景(将其设置为.clear),并仅在导航控制器栏处于活动状态时(单击)为其设置阴影 我怎样才能做到这一点 我试图在filterContentForSearchText(\uSearchText:String)内的导航控制器中设置阴影,但它不起作用: // Restore navigation bar line and set shadow na

我想在Swift中自定义
UISearchController
的外观

现在,我更改了占位符和搜索文本的字体和颜色,并更改了明文按钮图像

我需要删除搜索栏的背景(将其设置为.clear),并仅在导航控制器栏处于活动状态时(单击)为其设置阴影

我怎样才能做到这一点

我试图在
filterContentForSearchText(\uSearchText:String)
内的导航控制器中设置阴影,但它不起作用:

// Restore navigation bar line and set shadow
navigationController?.navigationBar.setBackgroundImage(nil, for: .default)
navigationController?.navigationBar.shadowImage = nil
navigationController?.navigationBar.layer.applyShadow(color: ViewUtil.color(red: 0, green: 49, blue: 105, alpha: 1), alpha: 0.1, x: 0, y: 6, blur: 9, spread: 0)
编辑:

非活动(这目前是正确的):

活动(我拥有的):

仅当搜索处于活动状态时我需要的内容:

请添加您想要的和您拥有的UI。@SagarChauhan请参阅编辑