views:

204

answers:

3

HI I'm trying to get a UITextField to look like the google search field available in the safari app on iPad. The purpose of the field will be the same (a search box).

I know i could use a UISearchBar but I would have to use hackish code to get rid of the magnifying glass icon and the background and I don't want that.

I'm attaching an image with the TextField used by apple as their search box. How can I modify an UITextField to look and behave like the search field in this screenshot? alt text

I tried to modified the UITextField's layer roundedCorners property but this doesn't work as expected.

Any help is very much appreciated!

Thank you!

A: 

Use a graphic with the rounded edges you want and then position a textview on top.

mbehan
Thanks for response but I don't think apple used something like that when they built that functionality.
Horatiu Paraschiv
It's a simple solution that works - if you want to do it the way apple done it, you'll have to ask them.
mbehan
A: 

Why don't you try a trick with making separate image of the input field you need and placing it under the real textField control. However, you will have to manipulate the colors of the textField you're placing over in order to make it transparent.

Sergei Lost
+1  A: 

You can set the Corner-Radius on any UIView-Subclass.

  1. Add the QuartzCore.framework to your project
  2. add #import <QuartzCore/QuartzCore.h> in your UIViewController Subclass (where you have access to the UITextfield instance of your choice
  3. within viewDidLoad / viewWillAppear (or any other place where your UITextfield is allready instantiated call [yourTextField.layer setCornerRadius:14.0f];
  4. play around with the cornerRadius value until it looks good

cheers

sam

samsam
While this is a great method for getting rounded corners, you won't get the exact look and feel he's showing. Specifically, the shadows.
Jerry Jones