当我的项目在Swift 2中时,我有这个代码有效:
extension UINavigationController {
func hairLine(hide: Bool) {
//hides hairline at the bottom of the navigationbar
for subview in self.navigationBar.subviews {
if subview.isKind(of: UIImageView.self) {
for hairline in subview.subviews {
if hairline.isKind(of: UIImageView.self) && hairline.bounds.height <= 1.0 {
hairline.isHidden = hide
}
}
}
}
}
}
但是现在发生了一些变化而且它无效。不确定是因为Swift 3,还是iOS10,或者我现在正在测试7plus vs 6s,但它不再有效。我会在其中调用正在显示的视图控制器的viewWillAppear。我在这里看到一个答案,说使用
UINavigationBar.appearance().shadowImage = UIImage()
UINavigationBar.appearance().setBackgroundImage(UIImage(), for: .default)
但这没效果。我尝试用这两行替换旧hairLine()的内容,尝试将它们直接放在viewWillAppear和viewDidAppear中,但仍然不适合我。
答案 0 :(得分:5)
Try this
Const wdFormatText = 2
If Not Len(Cells(1, "A").Value) > 0 Or Dir(Cells(1, "A").Value, vbDirectory) = "" Then
MsgBox ("Invalid Folder")
Exit Sub
End If
Dim StrFile As String
StrFile = Dir(Cells(1, "A").Value & "\*.docx")
Do While Len(StrFile) > 0
Set objWord = CreateObject("Word.Application")
Set objDoc = objWord.Documents.Open(Cells(1, "A").Value & "\" & StrFile, False, True)
objDoc.SaveAs Cells(1, "A").Value & "\" & StrFile & ".txt", wdFormatText
objWord.Quit
StrFile = Dir
Loop
答案 1 :(得分:2)
override func viewDidLoad() {
super.viewDidLoad()
navigationItem.title = "Hello World"
let navbarColor = UIColor(colorLiteralRed: (247/255), green: (247/255), blue: (247/255), alpha: 1)
let image = UIImage()
navigationController?.navigationBar.setBackgroundImage(image, for: .default)
navigationController?.navigationBar.shadowImage = image
navigationController?.navigationBar.backgroundColor = navbarColor
let statusBarHeight = UIApplication.shared.statusBarFrame.height
let statusBarWidth = UIScreen.main.bounds.size.width
let statusBarView = UIView(frame: CGRect(x: 0, y: 0, width: statusBarWidth, height: statusBarHeight))
statusBarView.backgroundColor = navbarColor
view.addSubview(statusBarView)
}
答案 2 :(得分:0)
尝试:
self.navigationController?.navigationBar.setBackgroundImage(_:UIImage(),
for: .any,
barMetrics: .default)
self.navigationController?.navigationBar.shadowImage = UIImage()
viewDidLoad()
中的
答案 3 :(得分:-1)
试试这个
UINavigationBar.appearance().setBackgroundImage(_:
nil,
for: .any,
barMetrics: .default)
UINavigationBar.appearance().shadowImage = nil