English 中文(简体)
怎样才能使一个比较四舍五入的UIText野? 和IPadSari的搜索场一样
原标题:How can i make a more rounded UITextField? Like the search field in Safari on iPad

HI I m试图找到一个UIText Field,像在iPad的聋.人手里可以找到的Agogle搜索场。 外地的目的相同(搜索箱)。

我知道,我可以使用UISearch Bar,但我不得不使用黑板法来清除大玻璃 i和背景,我不想这样做。

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

我试图修改UIText Field的几层环绕的卖主财产,但按预期,这只字不行。

任何帮助都受到高度赞赏!

谢谢!

问题回答

你可以把角角-拉迪乌斯排在任何情报室。

  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

使用以下代码。 它为我工作:

searchField= [[UITextField alloc] initWithFrame:CGRectMake(0,0,150,31)];
searchField.delegate = self;
searchField.autoresizingMask = UIViewAutoresizingFlexibleWidth;
searchField.textColor = [UIColor colorWithRed:102.0/255 green:102.0/255 blue:102.0/255 alpha:1.0];
searchField.textAlignment = UITextAlignmentLeft;
searchField.font = [UIFont fontWithName:@"Helvetica" size:15];
searchField.autocorrectionType = UITextAutocorrectionTypeNo;
searchField.contentVerticalAlignment =UIControlContentVerticalAlignmentCenter;
searchField.clearsOnBeginEditing = NO;
searchField.autocapitalizationType = UITextAutocapitalizationTypeNone;
searchField.autocorrectionType = UITextAutocorrectionTypeNo;
searchField.keyboardType = UIKeyboardTypeURL;
searchField.returnKeyType = UIReturnKeySearch;        
searchField.clearButtonMode = UITextFieldViewModeWhileEditing;
searchField.rightViewMode = UITextFieldViewModeUnlessEditing;
searchField.layer.cornerRadius = 17;
searchField.placeholder=@"Google Search";
searchField.borderStyle = UITextBorderStyleRoundedRect;//To change borders to rounded
searchField.layer.borderWidth = 1.0f; //To hide the square corners 
searchField.layer.borderColor = [[UIColor grayColor] CGColor]; //assigning the default border color
UIBarButtonItem *searchFieldItem = [[UIBarButtonItem alloc] initWithCustomView:searchField];

Set background property of UITextField to an appropriate image, like this one: alt text

为什么不要把你所需要的投入领域单独描绘成一滴,把它放在真正的文本中。 外地控制。 然而,你必须操纵案文的颜色。 为了使其具有透明度,你重新接任。





相关问题
Code sign Error

I have created a new iPhone application.I have two mach machines. I have created the certificate for running application in iPhone in one mac. Can I use the other mac for running the application in ...

ABPersonViewController Usage for displaying contact

Created a View based Project and added a contact to the AddressBook using ABAddressBookRef,ABRecordRef now i wanted to display the added contact ABPersonViewController is the method but how to use in ...

将音频Clips从Peter改为服务器

我不禁要问,那里是否有任何实例表明从Peit向服务器发送音响。 I m不关心电话或SIP风格的解决办法,只是一个简单的袖珍流程......

• 如何将搜查线重新定位?

我正试图把图像放在搜索条左边。 但是,问题始于这里,搜索条线不能重新布署。

热门标签