我在iOS 11的UIDocumentPicker导航栏中发现问题,完成,取消或编辑按钮是不可见的,当用户触摸它时,它会出现,即正常状态下的颜色是白色,甚至是更改UINavigationBar.appearnce().tintColor
时,颜色仅在触摸时更改。
答案 0 :(得分:4)
我不是在import matplotlib.pyplot as plt
from mpl_toolkits.axes_grid1 import ImageGrid
import numpy as np
numberOfPlots = 3
data = []
for i in range(numberOfPlots):
mean = i
data.append(np.random.normal(mean, size=(100,100)))
fig = plt.figure()
grid = ImageGrid(fig, 111, nrows_ncols=(1,numberOfPlots), cbar_mode='single')
ims = []
for i in range(numberOfPlots):
ims.append(grid[i].imshow(data[i]))
grid[i].set_title("Mean = " + str(i))
clims = [im.get_clim() for im in ims]
vmin = min([clim[0] for clim in clims])
vmax = max([clim[1] for clim in clims])
for im in ims:
im.set_clim(vmin=np.floor(vmin),vmax=np.ceil(vmax))
grid[0].cax.colorbar(ims[0]) # with cbar_mode="single", cax attribute of all axes are identical
fig.show()
和viewWillAppear
之间设置全局外观的忠实粉丝。外观API应仅在应用程序启动时使用。您可以通过将此代码放在viewWillDisappear
中来重置UIDocumentPickerViewController
的外观而不进行子类化,条形按钮将返回原始蓝色:
application:didFinishLaunchingWithOptions:
答案 1 :(得分:3)
For unknown reason I figured out that if you make a subclass of UIDocumentPicker using Objective-C
and set the [UINavigationBar appearance].tintColor = [UIColor black];
in viewWillAppear
func, and reset it to your defaults in the viewWillDisappear
, it works well.
But if you do the same steps using swift
it wont.
答案 2 :(得分:1)
对appearance
使用带有黑色UINavigationBar
的CustomDocumentPickerViewController和UIBarButtonItem
import UIKit
class CustomDocumentPickerViewController: UIDocumentPickerViewController {
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
UINavigationBar.appearance().tintColor = UIColor.black
UIBarButtonItem.appearance().setTitleTextAttributes([NSForegroundColorAttributeName : UIColor.black], for: .normal)
}
override func viewWillDisappear(_ animated: Bool) {
UINavigationBar.appearance().tintColor = UIColor.white // your color
UIBarButtonItem.appearance().setTitleTextAttributes(nil, for: .normal)
super.viewWillDisappear(animated)
}
}