我正在尝试创建一个这样的搜索栏:
但是我注意到我可能不得不用我自己的图像替换搜索栏,因为当我设置时,搜索栏的角落出错了:
self.searchController.searchBar.layer.cornerRadius = 50 // I've tried other numbers besides this too with no luck
self.searchController.searchBar.clipsToBounds = true
Run Code Online (Sandbox Code Playgroud)
如果我这样设置:
self.searchController.searchBar.layer.cornerRadius = self.searchController.searchBar.bounds.height/2
Run Code Online (Sandbox Code Playgroud)
搜索栏如下:
这仍然不像图像中那样精确.
有没有办法用图像替换文本字段的左侧和右侧,这样我可以使用自定义搜索栏中的圆角?