Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8769565
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T17:22:27+00:00 2026-06-13T17:22:27+00:00

I need a fully transparent searchbar with cancel button. I have tried many solutions

  • 0

I need a fully transparent searchbar with cancel button. I have tried many solutions But I couldnt find a better solution yet. When I try to remove background color it shows scope bar. Can any one give me some source code for fully transperant Searchbar with can button.
Here’s

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];

Need a fully transparent searchbar with cancel button and clear button but without scopebar.

Thanks in advance

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T17:22:28+00:00Added an answer on June 13, 2026 at 5:22 pm

    As of iOS 5.0 you can do the following:

    UIImage *imgClear = [UIImage imageNamed:@"clear"];
    [addSearchBar setImage:imgClear forSearchBarIcon:UISearchBarIconClear state:UIControlStateNormal];
    

    Thats it. You might also want to repeat the line for the UIControlStateHighlighted state.

    The last thing you should be doing is digging around inside the subviews of the search bar. It is guaranteed to break some day. Use the proper API to customize any control.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a scenario where I need a transparent background image but I have
I need to perform action, when my activity is fully loaded? Does Android have
I find myself with a need for a java utility for taking a fully-qualified
I have a project which fully designed for smart phone and now, I need
I've tried to create a fully transparent window using C++ & X11. It should
I am using Chrome browser. I have a fully transparent .png image for logo,
I have seen similar questions, but no answers that match exactly what I need.
This may be a silly question, but do I need Dajaxice fully configured to
When I write class templates, and need to fully-specialize members of those classes, Doxygen
I need a way to wait until a (Swing) JComponent is fully painted. This

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.