preferredStatusBarStyle .lightContent不适用于Navigation Controller

时间:2018-02-06 04:34:18

标签: ios iphone swift statusbar uistatusbar

preferredStatusBarStyle .lightContent不适用于导航控制器。我试过这个方法

override var preferredStatusBarStyle: UIStatusBarStyle { return .lightContent }

这是我第一次面对这类问题。此代码适用于我以前的应用程序。

我甚至在目标中改变了这一点:
I even change this in my target

2 个答案:

答案 0 :(得分:2)

我想您忘记在info.plist中更改状态栏样式

更改 info.plist 查看基于控制器的状态栏外观并将其设置为

并在您的ViewController中:

 override var preferredStatusBarStyle: UIStatusBarStyle { return .lightContent } 

无需其他代码

答案 1 :(得分:-1)

确保在Info.plist文件中将View controller-based status bar appearance设置为NO。检查您是否意外地在视图控制器中以编程方式将状态栏设置为不同的颜色也是有帮助的。如果您使用上述功能,是否致电self.setNeedsStatusBarAppearanceUpdate?但是,如果您将Light设置为项目设置中的值并将plist文件中的NO设置为didFinishLaunchingWithOptions,则根本不需要编写任何代码。

过去对我有用的另一个选项是在你的AppDelegate文件中,func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { UIApplication.shared.statusBarStyle = .lightContent return true } 函数执行此操作:

Sub CopyData()

    Dim shtSrc As Worksheet
    Dim c As Range, ws, r As Long, v

    Set shtSrc = ThisWorkbook.Sheets("Sheet1")

    For Each c In shtSrc.Range(shtSrc.Cells(2, 6), shtSrc.Cells(Rows.Count, 6).End(xlUp)).Cells
        v = c.Value
        If Len(v) > 0 Then
            With GetSheet(ThisWorkbook, v)
                'first row with no value in ColF
                r = .Cells(Rows.Count, 6).End(xlUp).Offset(1, 0).Row
                If r < 3 Then r = 3     'start at 3rd row
                .Rows(r).Value = c.EntireRow.Value 'copy row content (value only)
            End With
        End If
    Next c

End Sub


'Return a worksheet from a workbook: if not there, create a new sheet
'  with the supplied name and return that
Function GetSheet(wb As Workbook, theName) As Worksheet
    Dim ws As Worksheet
    On Error Resume Next
    Set ws = wb.Worksheets(theName)
    On Error GoTo 0
    If ws Is Nothing Then
        Set ws = wb.Worksheets.Add(after:=wb.Worksheets(wb.Worksheets.Count))
        ws.Name = theName
    End If
    Set GetSheet = ws
End Function