ios - 更改 ADAL iOS Auth 内的 UI 文本色调颜色

标签 ios swift uikit adal

在我的应用程序委托(delegate)中,我已将全局默认色调设置为白色,因为我的应用程序中的所有导航栏都是黑色的。当 ADALiOS 对用户进行身份验证时,我会看到如下图所示的屏幕。如果您仔细观察,您可以在左上角看到白色字母的“取消”按钮。

是否有任何解决方法可以将文本颜色或导航栏颜色更改为黑色?

viewDidLoad()内部我调用以下方法:

    authManager.login() {
            (authenticated: Bool, token: String) -> Void in
            if (authenticated) {
                self.setupMapView()
                self.getJSON()
            } else {
                print("Authentication Failed!")
                self.loginToolbar.alpha = 1.0
                self.listButton.enabled = false
                self.filterButton.enabled = false
                self.refreshButton.enabled = false
            }
        } 

这是我的 AuthManager 类中的 login() 函数:

func login(completionBlock:((Bool, String) -> Void)) {
            var er:ADAuthenticationError? = nil
    let authContext = ADAuthenticationContext(authority: authority, error: &er)
    var token: String!
    authContext.acquireTokenWithResource(resourceURI, clientId: clientID, redirectUri: redirectURI, userId: NSUserDefaults.standardUserDefaults().stringForKey("username")) {
        (result: ADAuthenticationResult!) -> Void in
        if result.status.rawValue != AD_SUCCEEDED.rawValue {
            completionBlock(false, result.error.description)
        } else {
            token = result.accessToken
            let username = result.tokenCacheStoreItem.userInformation.userId
            self.storeUsername(username)
            completionBlock(true, token)
        }
    }
}

Color of Cancel button in top left corner is white.

最佳答案

如果您查看 ADAL 提供的 AuthenticationContext 上的属性,您会发现有一些 ViewController 属性,例如:父级、子级等。

ADAuthenticationContext 还允许您访问 .webView 属性。也许通过这条途径可以进行定制。

网页 View :

_authContext.webView.inputViewController?.navigationController?.navigationBar.barTintColor = .black

父 View

_authContext.parentController.navigationController?.navigationBar.tintColor = .black

我尝试访问家长导航栏,但没有看到任何成功。

本周我也一直在解决这个问题,似乎找不到直接的解决方案,但是我想分享我的发现,希望它可以帮助您解决问题。也许其中一些可以引导我们访问 Controller 的导航栏,但我认为最终需要更改栏设置,例如色调/标题/颜色。

如果我能正常工作,将发布进一步的回复。如果您自己解决了,请更新。

更新:我通过简单地添加我的 AppDelegate 就解决了这个问题。

UINavigationBar.appearance().barStyle = .blackOpaque
UINavigationBar.appearance().tintColor = .white

如果您只需要单个页面,您可以在 viewController 的 Appear/Disappear 方法中切换此功能。

关于ios - 更改 ADAL iOS Auth 内的 UI 文本色调颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38616219/

相关文章:

swift - NSCalendar.startOfDayForDate(日期 :) equivalent for iOS 7 with non-optional return type

ios - 在 iOS 中构建允许 WiFi 扬声器流式传输音乐的 RTP 服务器

ios - Testflight工作流程

iphone - 如何从另一个函数调用 id sender 函数?

ios - 在 swift 中使用 Realm 创建索引 TableView

c++ - 如何使用 IOConnectCallStructMethod 发送数据作为输入

ios - 在 UITextfield 上订阅(控制事件,编辑已更改)

ios - viewWillTransitionToSize : vs willTransitionToTraitCollection:

ios - 你打电话吗[super viewDidDisappear :animated] in iOS?

ios - 在同一个 NSAttributedString 中使用多种不同颜色对链接进行着色