Good day. Customize SearchBar custom. And stumbled upon a problem that I can not solve. The "Cansel" -> "Cancel" button has some kind of gray shadow, and I cannot disable it. As I just did not try to do it.

cancelButton.titleLabel.shadowColor = [UIColor greenColor]; //Цвет для теста cancelButton.titleLabel.layar.shadowColor = [UIColor greenColor]; cancelButton.titleLabel.textColor = [UIColor redColor]; cancelButton.titleLabel.backgroundColor = [UIColor redColor]; 

Nothing helps to remove this effect. alt text

alt text

Tried even to lay down UILable on button but unsuccessfully. Tell me how to do it !!!

Thanks in advance

    2 answers 2

    I think these are attributes of the text, try something like this:

      NSDictionary *attributes = [NSDictionary dictionaryWithObjectsAndKeys: [UIColor whiteColor], UITextAttributeTextColor, [UIColor colorWithRed:0 green:0 blue:0 alpha:0], UITextAttributeTextShadowColor, [NSValue valueWithUIOffset:UIOffsetMake(0, 0)], UITextAttributeTextShadowOffset, [UIFont systemFontOfSize:12], UITextAttributeFont, nil]; [[UIBarButtonItem appearanceWhenContainedIn:[UISearchBar class], nil] setTitleTextAttributes:attributes forState:UIControlStateNormal]; [[UIBarButtonItem appearanceWhenContainedIn:[UISearchBar class], nil] setTitleTextAttributes:attributes forState:UIControlStateHighlighted]; 
    • I tried this, did not help = ( - Svyatoslav Boyko
    • Okay, I'll try at home. - BiMaWa
    • I did everything! Thank! - Svyatoslav Boyko
    • one
      from damn, okay at home , I pick another thread) - BiMaWa

    Is there an ordinary button like UIButton? If so, then for its titleLabel it is necessary to pull not directly the parameters, but through the UIButton methods of the form - (void)setTitleShadowColor:(UIColor *)color forState:(UIControlState)state otherwise, the button will change the properties you set when changing the state of the button. Have you tried to do that?

    • I have a function that catches any breath of this button and, when it is activated, always forces it to apply parameters. Now I will try with your methods! and accomplish your goal! - Svyatoslav Boyko
    • Doesn't want to ... - Svyatoslav Boyko
    • one
      Can you get this piece out and publish it somewhere? I would look at the code then. - aknew