• IOS 修改UISearchBar 输入框的颜色 placeholder字体的颜色


    UISearchBar *searchBar = [UISearchBar alloc] initWithFrame:CGRectMake(0, 0, 100, 30)];

    for (UIView* subview in [[searchBar.subviews lastObject] subviews]) {

            if ([subview isKindOfClass:[UITextField class]]) {

                UITextField *textField = (UITextField*)subview;

                 textField.textColor = [UIColor redColor];                         //修改输入字体的颜色

                [textField setBackgroundColor:[UIColor grayColor]];      //修改输入框的颜色
                [textField setValue:[UIColor whiteColor] forKeyPath:@"_placeholderLabel.textColor"];   //修改placeholder的颜色
            } else if ([subview isKindOfClass:NSClassFromString(@"UISearchBarBackground")])
            {
                [subview removeFromSuperview];
            }
        }

  • 相关阅读:
    算法复习:字符串
    【第五天打卡。
    【第四天打卡。
    【第三天打卡。
    第二天打卡。
    【唉
    配环境到崩溃系列
    所谓环境……
    【随便吐槽
    第四天。打卡。【偷懒了两天hhhh
  • 原文地址:https://www.cnblogs.com/mkai/p/6381342.html
Copyright © 2020-2023  润新知