所以我以前将搜索控制器嵌入到导航栏中,以便导航栏的渐变也覆盖了搜索栏。
突然间,我相信通过XCode更新,我发现现在导航栏的背景色牢牢地停在搜索控制器的顶部。我很难查明发生这种情况的原因。
这是我当前的代码,以前有效。有什么想法吗?
Traceback (most recent call last):
File "<>", line 7, in <module>
wb.save('practicewb')
File "C:\Program Files (x86)\Python37-32\lib\site-packages\openpyxl\workbook\workbook.py", line 409, in save
save_workbook(self, filename)
File "C:\Program Files (x86)\Python37-32\lib\site-packages\openpyxl\writer\excel.py", line 294, in save_workbook
writer.save()
File "C:\Program Files (x86)\Python37-32\lib\site-packages\openpyxl\writer\excel.py", line 276, in save
self.write_data()
File "C:\Program Files (x86)\Python37-32\lib\site-packages\openpyxl\writer\excel.py", line 76, in write_data
self._write_worksheets()
File "C:\Program Files (x86)\Python37-32\lib\site-packages\openpyxl\writer\excel.py", line 216, in _write_worksheets
self.write_worksheet(ws)
File "C:\Program Files (x86)\Python37-32\lib\site-packages\openpyxl\writer\excel.py", line 201, in write_worksheet
writer.write()
File "C:\Program Files (x86)\Python37-32\lib\site-packages\openpyxl\worksheet\_writer.py", line 356, in write
self.write_rows()
File "C:\Program Files (x86)\Python37-32\lib\site-packages\openpyxl\worksheet\_writer.py", line 124, in write_rows
self.write_row(xf, row, row_idx)
File "C:\Program Files (x86)\Python37-32\lib\site-packages\openpyxl\worksheet\_writer.py", line 133, in write_row
attrs.update(dims.get(row_idx, {}))
TypeError: 'int' object is not iterable
Error in atexit._run_exitfuncs:
Traceback (most recent call last):
File "C:\Program Files (x86)\Python37-32\lib\site-packages\openpyxl\worksheet\_writer.py", line 33, in _openpyxl_shutdown
os.remove(path)
PermissionError: [WinError 32] The process cannot access the file because it is being used by another process: 'C:\\Users\\philt\\AppData\\Local\\Temp\\openpyxl.gtzivgcp'
Process finished with exit code 1
答案 0 :(得分:1)
该代码有两个问题。首先,停止入侵搜索栏:
self.searchController.searchBar.barTintColor = UIColor.clear // no
self.searchController.searchBar.backgroundImage = UIImage() // no
searchController.searchBar.backgroundColor = UIColor.clear // no
searchController.searchBar.barStyle = .blackTranslucent // no
第二,停止入侵导航栏:从您的代码中完全删除GradientView。
class GradientView: UIView { // no
只需使用框架提供的工具即可。设置导航栏的背景图像(为渐变图像)并 stop 。搜索控制器的搜索栏会自动自动将其正确集成到导航栏中:
编辑好的,事实证明,这仅是iOS 13的问题。那是因为您要做的不是在iOS 13中如何向导航栏添加背景图像。您必须将代码分叉:
if #available(iOS 13.0, *) {
let app = UINavigationBarAppearance()
app.backgroundImage = im // the gradient image
self.navigationController?.navigationBar.scrollEdgeAppearance = app
self.navigationController?.navigationBar.standardAppearance = app
} else {
// your old code goes here
}
答案 1 :(得分:0)
可处理ios 12和13的Swift 5。
这是基于哑光的答案。
if #available(iOS 13.0, *) {
let app = UINavigationBarAppearance()
app.backgroundImage = UIImage(named: "img")
self.navigationController?.navigationBar.scrollEdgeAppearance = app
self.navigationController?.navigationBar.standardAppearance = app
} else {
// iOS 12 to below
if let navigationbar = self.navigationController?.navigationBar {
navigationbar.barTintColor = UIColor(patternImage: UIImage(named: "img")!)
navigationbar.isTranslucent = false
}
}