0

I am unable to set frame of UISearchBarTextField.... Should I create my own Search Bar or Is there a way to do the above?

https://github.com/nst/iOS-Runtime-Headers/blob/master/Frameworks/UIKit.framework/UISearchBarTextField.h

Marco
  • 6,692
  • 2
  • 27
  • 38
sargeras
  • 179
  • 1
  • 14

2 Answers2

2

in iOS 7 to access Text Field you have to reiterate on level more. Change your code like this

for (UIView *subView in self.searchBar.subViews){
    for (UIView *2ndLeveSubView in subView.subViews){
    if ([2ndLeveSubView isKindOfClass:[UITextField class]])
        {
            searchBarTextField = (UITextField *)2ndLeveSubView;

            break;
        }
    }
   }

But best way to clear backgournd of UISearchBar and setting searchbar icon in text field is:

[searchBar setBackgroundImage:[[UIImage alloc] init] ];//if you want to remove background of uisearchbar
UIImage *image = [UIImage imageNamed: @"search_icon.png"];
[searchBar setImage:image forSearchBarIcon:UISearchBarIconSearch state:UIControlStateNormal];
kagmanoj
  • 5,038
  • 5
  • 19
  • 21
-5

Have you try this.

 [searchBarObj setFrame:CGRectMake(44, 0, 320 - 44, 43)];
Ayaz
  • 1,398
  • 15
  • 29