草庐IT

textfield

全部标签

ios - 更改 UISearchBar 的 textField 的背景

我为此苦苦挣扎了一段时间。到处搜索,但提供的解决方案仅适用于objective-c。其中包括UITextField*txt=[_searchBarvalueForKey:@"_searchField"];虽然有些人可能会说这是protectedAPI,Apple可能会拒绝使用此类代码的应用。所以,现在我已经尝试了很多方法来解决这个问题,但它根本不起作用。我的代码是这样的:searchBar=UISearchBar(frame:CGRectMake(0,0,320.0,30.0))searchBar.autoresizingMask=UIViewAutoresizing.Flexible

ios - 更改 UISearchBar 的 textField 的背景

我为此苦苦挣扎了一段时间。到处搜索,但提供的解决方案仅适用于objective-c。其中包括UITextField*txt=[_searchBarvalueForKey:@"_searchField"];虽然有些人可能会说这是protectedAPI,Apple可能会拒绝使用此类代码的应用。所以,现在我已经尝试了很多方法来解决这个问题,但它根本不起作用。我的代码是这样的:searchBar=UISearchBar(frame:CGRectMake(0,0,320.0,30.0))searchBar.autoresizingMask=UIViewAutoresizing.Flexible

ios - 无法更改搜索栏背景颜色

我有一个搜索栏:letsearchBar:UISearchBar=UISearchBar(frame:CGRectMake((searchView.frame.width-UIScreen.mainScreen().bounds.width/1.6)/2,0,UIScreen.mainScreen().bounds.width/1.6,24))我想更改文本输入部分的背景颜色。为此,我尝试了:searchBar.barTintColor=UIColor(red:0/255,green:74/255,blue:103/255,alpha:1)searchBar.backgroundColo

ios - 无法更改搜索栏背景颜色

我有一个搜索栏:letsearchBar:UISearchBar=UISearchBar(frame:CGRectMake((searchView.frame.width-UIScreen.mainScreen().bounds.width/1.6)/2,0,UIScreen.mainScreen().bounds.width/1.6,24))我想更改文本输入部分的背景颜色。为此,我尝试了:searchBar.barTintColor=UIColor(red:0/255,green:74/255,blue:103/255,alpha:1)searchBar.backgroundColo

swift - 在 Swift 中使用 stringByReplacingCharactersInRange

我正在尝试在Swift/Xcode6中使用UITextFieldDelegate,但我正在努力解决我应该使用stringByReplacingCharactersInRange的方式。编译器错误是“无法将表达式的类型‘String’转换为类型‘$T8’”。functextField(textField:UITextField!,shouldChangeCharactersInRangerange:NSRange,replacementStringstring:String!)->Bool{lets=textField.text.stringByReplacingCharactersIn

swift - 在 Swift 中使用 stringByReplacingCharactersInRange

我正在尝试在Swift/Xcode6中使用UITextFieldDelegate,但我正在努力解决我应该使用stringByReplacingCharactersInRange的方式。编译器错误是“无法将表达式的类型‘String’转换为类型‘$T8’”。functextField(textField:UITextField!,shouldChangeCharactersInRangerange:NSRange,replacementStringstring:String!)->Bool{lets=textField.text.stringByReplacingCharactersIn

swift - 使用 Swift 选择 UITextField 中的所有文本

如何以编程方式选择Swift文本字段中的所有文本?vartextField:UITextField=UITextField()textField.frame=CGRectMake(2,25,200,20)textField.text="hello"textField.font=UIFont(name:"Verdana",size:12)textField.textColor=UIColor.blackColor()textField.backgroundColor=UIColor.whiteColor()或者至少让文本立即可编辑?谢谢安德鲁 最佳答案

swift - 使用 Swift 选择 UITextField 中的所有文本

如何以编程方式选择Swift文本字段中的所有文本?vartextField:UITextField=UITextField()textField.frame=CGRectMake(2,25,200,20)textField.text="hello"textField.font=UIFont(name:"Verdana",size:12)textField.textColor=UIColor.blackColor()textField.backgroundColor=UIColor.whiteColor()或者至少让文本立即可编辑?谢谢安德鲁 最佳答案

ios - 在 UItextfield 的右 View 上添加一个按钮,文本不应与按钮重叠

我可以使用右View将按钮添加到UITextField右侧的文本字段,但是,文本重叠在按钮上。下面是右View按钮的代码UIView.commitAnimations()varbtnColor=UIButton(type:.Custom)btnColor.addTarget(self,action:#selector(self.openEmoji),forControlEvents:.TouchUpInside)btnColor.frame=CGRect(x:CGFloat(textField.frame.size.width-25),y:CGFloat(5),width:CGFloa

ios - 在 UItextfield 的右 View 上添加一个按钮,文本不应与按钮重叠

我可以使用右View将按钮添加到UITextField右侧的文本字段,但是,文本重叠在按钮上。下面是右View按钮的代码UIView.commitAnimations()varbtnColor=UIButton(type:.Custom)btnColor.addTarget(self,action:#selector(self.openEmoji),forControlEvents:.TouchUpInside)btnColor.frame=CGRect(x:CGFloat(textField.frame.size.width-25),y:CGFloat(5),width:CGFloa