开发者

how to add button to UISearchBar

how to add button to UISearchBar

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

its for iphone.

Please help me out.

@ 开发者_开发百科thanks in advance.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜