Ho bisogno di una barra di ricerca completamente trasparente con pulsante Annulla. Ho provato molte soluzioni ma non ho ancora trovato una soluzione migliore. Quando provo a rimuovere il colore di sfondo mostra la barra di campo. Qualcuno può darmi qualche codice sorgente per Searchbar completamente transperant con pulsante can. EccoCome modificare l'immagine del pulsante di cancellazione (pulsante x) o almeno il colore dell'immagine del pulsante di cancellazione in UISearchbar?
addSearchbar.backgroundColor = [UIColor colorWithRed:1.0 green:1.0 blue:1.0 alpha:0.5];
UITextField *sbTextField = (UITextField *)[self.addSearchbar.subviews lastObject];
for (UIView *subview in addSearchbar.subviews)
{
NSLog(@"%@",subview);
if ([subview isKindOfClass:[UITextField class]])
{
sbTextField = (UITextField *)subview;
UIImage *image = [UIImage imageNamed: @"06_magnifying_glass.png"];
UIImageView *iView = [[UIImageView alloc] initWithImage:image];
iView.frame = CGRectMake(0, 0, 24, 24);
sbTextField.leftView.frame = CGRectMake(0, 0, 24, 24);
sbTextField.leftView = iView;
[sbTextField.rightView removeFromSuperview];
CGFloat myWidth = 24.0f;
CGFloat myHeight = 24.0f;
UIButton *myButton = [[UIButton alloc] initWithFrame:CGRectMake(0.0f, 0.0f, myWidth, myHeight)];
[myButton setImage:[UIImage imageNamed:@"clear.png"] forState:UIControlStateNormal];
[myButton setImage:[UIImage imageNamed:@"clear.png"] forState:UIControlStateHighlighted];
[myButton addTarget:self action:@selector(doClear:) forControlEvents:UIControlEventTouchUpInside];
sbTextField.rightView = myButton;
sbTextField.rightViewMode = UITextFieldViewModeWhileEditing;
break;
}
if([subview isMemberOfClass:[UISegmentedControl class]])
{
UISegmentedControl *scopeBar=(UISegmentedControl *) subview;
scopeBar.tintColor = [UIColor clearColor];
}
}
[sbTextField removeFromSuperview];
[addSearchbar addSubview:sbTextField];
[addSearchbar setSearchFieldBackgroundImage:[UIImage imageNamed:@"SearchBar.png"] forState:UIControlStateNormal];
CGRect sbFrame = self.addSearchbar.frame;
// Set the default height of a textfield
sbFrame.size.height = 31;
/* 8 is the top padding for textfield inside searchbar
* You may need to add a variable to 8 according to your requirement.
*/
sbFrame.origin.y = 6+self.addSearchbar.frame.origin.y;
sbTextField.frame = sbFrame;
sbTextField.textColor = [UIColor lightGrayColor];
[sbTextField setAutoresizingMask:UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleBottomMargin];
bisogno di una barra di ricerca completamente trasparente con pulsanti e chiara, ma senza scopebar annullare.
Grazie in anticipo
http://stackoverflow.com/questions/9704562/remove-or- override-the-clear-button-on-uisearchdisplaycontroller-in-a-uipopove –
Ho trovato la soluzione ma un altro pblm così ho aggiornato le mie domande – Arvind