小编mha*_*ddl的帖子

UISearchbar barTintColor取消按钮不可见

我尝试将UISearchbar的条形颜色设置为一种颜色,将tintColor(光标和取消按钮)设置为另一种颜色,代码如下:

searchbar.barTintColor = color1;
searchbar.tintColor = color2;
Run Code Online (Sandbox Code Playgroud)

barTintColor正确应用.

问题是:取消按钮的文本不可见,但如果在故事板中尝试相同(将batTintColor和tintColor应用于UISearchbar),一切都按预期工作.

uisearchbar tintcolor ios7 bartintcolor

7
推荐指数
1
解决办法
1257
查看次数

使用UNNotificationContentExtension显示自定义UI以进行本地通知

我正在尝试使用新的UNNotificationContentExtension来显示本地通知的自定义用户界面,但只显示默认通知警报.

我使用Xcode模板创建了扩展,并UNNotificationExtensionCategory在Info.plist中指定了该扩展. 在此输入图像描述

在此之后,我注册了通知和设置UNNotificationCategoryapplication(_:didFinishLaunchingWithOptions:)

    let center = UNUserNotificationCenter.current()
    center.requestAuthorization([.alert, .sound]) { (granted, error) in
        // Enable or disable features based on authorization.
    }

    let action = UNNotificationAction(identifier: "Delete", title: "Delete", options: [])

    let category = UNNotificationCategory(identifier: "notify-test", actions: [action], minimalActions: [], intentIdentifiers: [], options: [])
    UNUserNotificationCenter.current().setNotificationCategories([category])
Run Code Online (Sandbox Code Playgroud)

我安排通知在应用程序使用此代码进入后台后五秒触发:

    let content = UNMutableNotificationContent()
    content.title = NSString.localizedUserNotificationString(forKey: "Hello!", arguments: nil)
    content.body = NSString.localizedUserNotificationString(forKey: "Hello_message_body", arguments: nil)
    content.sound = UNNotificationSound.default()
    content.categoryIdentifier = "notify-test"

    let trigger = UNTimeIntervalNotificationTrigger.init(timeInterval: 5, repeats: false) …
Run Code Online (Sandbox Code Playgroud)

uikit ios swift ios10 unnotificationrequest

5
推荐指数
2
解决办法
5131
查看次数

名称和邮件范围的ASAuthorizationAppleIDRequest返回nil值

我正在使用Apple实施Sign in,并注意到返回的emailfullName属性ASAuthorizationAppleIDCredential仅在此Apple ID的第一个Sign-In上填写。在所有后续登录中,这些属性均为零。

这是iOS 13上的错误还是预期的行为?

这是我用来启动请求的代码:

@available(iOS 13.0, *)
dynamic private func signInWithAppleClicked() {
    let request = ASAuthorizationAppleIDProvider().createRequest()
    request.requestedScopes = [.fullName, .email]

    let controller = ASAuthorizationController(authorizationRequests: [request])
    controller.delegate = self
    controller.presentationContextProvider = self
    controller.performRequests()
}
Run Code Online (Sandbox Code Playgroud)

我正在此委托方法中收到证书:

public func authorizationController(controller: ASAuthorizationController, didCompleteWithAuthorization authorization: ASAuthorization) {
    guard let credential = authorization.credential as? ASAuthorizationAppleIDCredential else { return }

    let userIdentifier = credential.user
    let token = credential.identityToken
    let authCode = credential.authorizationCode
    let realUserStatus = credential.realUserStatus
    let mail = …
Run Code Online (Sandbox Code Playgroud)

ios13 xcode11 apple-sign-in

5
推荐指数
5
解决办法
472
查看次数