Like iBooks, like a desktop search user interface

I want to show the search bar as a table in iBooks. How can I reduce the width of the search bar and how it can be shown without any background color.

Also how can I hide the search box when the page is displayed.

enter image description here

+3
source share
1 answer

I can imagine two options:

Create your own by subclassing UITextfield

  • set border style to UITextBorderStyleNone
  • set the left image to the magnifying glass image.
  • set the background to transparent png with only a round border showing
  • use if uiimages stretchableImageWithLeftCapWidth: method is topCapHeight, so the background image will look nice when stretched

UISearchbar,

UISearchbar :

for (UIView *aSubview in [searchbar subviews]) {
            // this will remove the toolbar around the searchbar in iOS 4
    if ([aSubview isKindOfClass:NSClassFromString(@"UISearchBarBackground")]) 
    {
        [aSubview removeFromSuperview];
    }       

    // get a grip on the underlying textfield...
    if ([aSubview isKindOfClass:NSClassFromString(@"UISearchBarTextField")]) 
    {
        UITextField *aTextfield = (UITextField *)aSubview;

        // this won't do anything at it is already none, just experimenting
        aTextfield.borderStyle = UITextBorderStyleNone;

        // this will remove the whole border as it is a custom background
        aTextfield.background = nil;

        // this will remove the magnifying glass
        aTextfield.leftView = nil;

        // play around even more :)
    }       
}

  • YES
  • -
  • 0.0:
+6

All Articles