kiran kumar
kiran kumar

Reputation: 1359

how to add button to UISearchBar

alt text

I need to implement like above figure... How to add button to UISearch Bar.

its for iphone.

Please help me out.

@ thanks in advance.

Upvotes: 2

Views: 3203

Answers (1)

Warrior
Warrior

Reputation: 39374

For this purpose you need to create a class(MyScearchBar) whose parent class will be UISearchBar. I that class

 -(void)layoutSubviews
{

self.autoresizesSubviews = YES;
textField = [self.subviews objectAtIndex:1];
textField.delegate = self;
[textField setFrame:CGRectMake(90,5,250,31)];
textField.backgroundColor=[UIColor clearColor];

settings=[UIButton buttonWithType:UIButtonTypeRoundedRect];
[settings setFrame:CGRectMake(10, 10, 70, 50)];
[self addSubview:settings];

}

your code instead of using UIsearchbar, use the new class name you have created(MySearchBar).

ie MySearchBar search=[[MySearchBar alloc]init];

All the best.

Upvotes: 3

Related Questions