uitextfield

UISearchBar custom corners

纵饮孤独 提交于 2019-12-18 15:13:34
问题 I'm trying to create a search bar like this: But I'm noticing that I'm probably going to have to replace the search bar with my own image because the search bar corners comes out wrong when I set: self.searchController.searchBar.layer.cornerRadius = 50 // I've tried other numbers besides this too with no luck self.searchController.searchBar.clipsToBounds = true If I set this: self.searchController.searchBar.layer.cornerRadius = self.searchController.searchBar.bounds.height/2 The search bar

UITextField's keyboard won't dismiss. No, really

亡梦爱人 提交于 2019-12-18 12:16:53
问题 I have a table view in a modal form sheet (iPad), and one of the cells contains a UITextField. My view controller holds a reference to the text field and is also its delegate. When the text field hits Return, I tell it to -resignFirstResponder inside of -textFieldShouldReturn: . In another case, I want to force it to end editing, so I tell the whole table view to -endEditing:YES . Afterwards I release my local reference to the text field, and reload the row to replace it with something else.

How to check if UITextField's text is valid email?

有些话、适合烂在心里 提交于 2019-12-18 11:35:17
问题 I have a view controller with 3 UITextFields (username, email, and password). I need a method that checks first, if all fields have text in them, then check if the email's textfield is a valid email, perhaps by checking if it has an @ sign in it. Can anyone help with this? 回答1: This will check a UITextField for a proper email. Add this method to the textFields delegate then check if the characters it is about to change should be added or not. Return YES or NO depending on the text fields

Customize UITextfield of the UISearchbar - iOS

冷暖自知 提交于 2019-12-18 11:11:12
问题 I'm trying to customize the textfield for the UISearchbar. The picture below shows my half done work. I have subclasses the UISearchbar and called it from my view controller. I'm trying to remove those dark gray lines from the textfield. Below is the implementation of the UISearchbar adding to subview of the viewcontroller. searchbar = [[SearchBar alloc] initWithFrame:CGRectMake(35,78, 250, 17)]; searchbar.backgroundColor = [UIColor clearColor]; searchbar.layer.borderColor = [[UIColor

UITextField text jumps

好久不见. 提交于 2019-12-18 10:59:29
问题 I have ViewController with 2 UITextField elements: Login and Password. I set delegate for these fields, which includes code below: func textFieldShouldReturn(textField: UITextField) -> Bool { if textField === self.loginField { self.loginField.resignFirstResponder() self.passwordField.becomeFirstResponder() return false } return true } This logic should switch user from login text field to password when he presses Next button on keyboard. But I stuck with glitch: after self.passwordField

UITextField text jumps

半城伤御伤魂 提交于 2019-12-18 10:59:22
问题 I have ViewController with 2 UITextField elements: Login and Password. I set delegate for these fields, which includes code below: func textFieldShouldReturn(textField: UITextField) -> Bool { if textField === self.loginField { self.loginField.resignFirstResponder() self.passwordField.becomeFirstResponder() return false } return true } This logic should switch user from login text field to password when he presses Next button on keyboard. But I stuck with glitch: after self.passwordField

What's the default color for placeholder text in UITextField?

放肆的年华 提交于 2019-12-18 10:06:25
问题 Does anyone know what color a UITextField 's placeholder text is, by default? I'm trying to set a UITextView 's text to the same color. I've read elsewhere that it is UIColor.lightGrayColor() but it is actually a little lighter. 回答1: You can get this colour from inspecting the attributedPlaceholder from the UITextField . The default seems to be: NSColor = "UIExtendedSRGBColorSpace 0 0 0.0980392 0.22"; You could add an extension (or category) on UIColor : extension UIColor { static var

UITextField not scrolling horizontally

£可爱£侵袭症+ 提交于 2019-12-18 08:53:07
问题 I am trying to make a small calculator app. When a UIButton is pressed, the Button title is added to a UITextField. kind of: myuitextfield.text = [myuitextfield.text stringByAppendingString:[button currentTitle]; When I reach the end of my textfield, the text gets truncated. How can I disable this, so the textfield starts scrolling automatically and allows adding more characters? I tried every possible option in Interface Builder, without any luck. Isn't the UITextField supposed to scroll

UITextField not scrolling horizontally

一笑奈何 提交于 2019-12-18 08:52:00
问题 I am trying to make a small calculator app. When a UIButton is pressed, the Button title is added to a UITextField. kind of: myuitextfield.text = [myuitextfield.text stringByAppendingString:[button currentTitle]; When I reach the end of my textfield, the text gets truncated. How can I disable this, so the textfield starts scrolling automatically and allows adding more characters? I tried every possible option in Interface Builder, without any luck. Isn't the UITextField supposed to scroll

UIAlertController - change size of text fields and add space between them

情到浓时终转凉″ 提交于 2019-12-18 08:33:28
问题 My alert looks like this: Is it possible to make inputs bigger and add space between them? Here is a snippet from my code. I tried changing the frame property of the second text field but it didn't help: let alert = UIAlertController(title: title, message: message, preferredStyle: .Alert) // Add the textfields alert.addTextFieldWithConfigurationHandler({ (textField) -> Void in textField.placeholder = "Vaše jméno" }) alert.addTextFieldWithConfigurationHandler({ (textField) -> Void in textField