【OC】修改UISearchBar中的placeholderLabel的颜色和字体大小

找到searchbar的searchField属性通过KVC修改属性值

    UITextField *searchField = [searchBar valueForKey:@"_searchField"];
    if (searchField) {
        [searchField setValue:[UIColor blackColor] forKeyPath:@"_placeholderLabel.textColor"];
        [searchField setValue:[UIFont systemFontOfSize:13] forKeyPath:@"_placeholderLabel.font"];
    }

你可能感兴趣的:(【OC】修改UISearchBar中的placeholderLabel的颜色和字体大小)