Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iOS 13 下 UISearchBar.qmui_placeholderColor 在某些时机下设置时无效 #830

Closed
JaminZhou opened this issue Nov 22, 2019 · 4 comments

Comments

@JaminZhou
Copy link

iOS13 UISearchBar的searchTextField.attributedPlaceholder 现在是无解吗?设置NSForegroundColor没有用

@MoLice
Copy link
Collaborator

MoLice commented Nov 22, 2019

iOS 13 下系统的 UISearchBar.textField.attributedPlaceholder 机制有些变化,导致某些场景修改 placeholder 无效,我们再看看怎么解决。在此之前你可以尝试把 placeholderColor 的修改时机延后到 viewWillAppear: 或者 viewDidAppear: 后。

@MoLice MoLice changed the title qmui_placeholderColor iOS 13 下 UISearchBar.qmui_placeholderColor 在某些时机下设置时无效 Nov 22, 2019
@MoLice
Copy link
Collaborator

MoLice commented Nov 27, 2019

在新版本发布之前,可以先将以下代码添加到 UISearchBar+QMUI.m 的 +load 方法内:

if (@available(iOS 13.0, *)) {
    ExtendImplementationOfVoidMethodWithoutArguments([UISearchBar class], @selector(didMoveToWindow), ^(UISearchBar *selfObject) {
        if (selfObject.qmui_placeholderColor) {
            selfObject.placeholder = selfObject.placeholder;
        }
    });
}

@MoLice MoLice added the bug label Nov 27, 2019
@JaminZhou
Copy link
Author

在新版本发布之前,可以先将以下代码添加到 UISearchBar+QMUI.m 的 +load 方法内:

if (@available(iOS 13.0, *)) {
    ExtendImplementationOfVoidMethodWithoutArguments([UISearchBar class], @selector(didMoveToWindow), ^(UISearchBar *selfObject) {
        if (selfObject.qmui_placeholderColor) {
            selfObject.placeholder = selfObject.placeholder;
        }
    });
}

感谢!

@MoLice
Copy link
Collaborator

MoLice commented Dec 9, 2019

已发布 4.0.4 修复该问题。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants