uitextfield

Creating a textfield with only bottom Line in Ios

倖福魔咒の 提交于 2019-11-30 11:10:44
Is is possible to create a Textfield in Ios which shows only bottom border line and not upper and side lines. if Yes, how can i implement this Yes it is possible. Here is how to do it: CALayer *border = [CALayer layer]; CGFloat borderWidth = 2; border.borderColor = [UIColor darkGrayColor].CGColor; border.frame = CGRectMake(0, textField.frame.size.height - borderWidth, textField.frame.size.width, textField.frame.size.height); border.borderWidth = borderWidth; [textField.layer addSublayer:border]; textField.layer.masksToBounds = YES; Hope this helps!! Updated for Swift 3.0 extension UITextField

Dismissing keyboard from UISearchBar when the X button is tapped

非 Y 不嫁゛ 提交于 2019-11-30 11:05:15
问题 I'm using the UISearchBar (but not the SearchDisplayController that's typically used in conjunction) and I'd like to dismiss the keyboard when you hit the 'X' button. I've followed TomSwift's suggestion on getting called when the 'X' is tapped and that works great. But resigning first responder from the text field and also invoking in the UISearchBar instance, both with resignFirstResponder , won't make the keyboard go away. Is there a way to get rid of the keyboard when the user has tapped

Disable blinking cursor in UITextField?

随声附和 提交于 2019-11-30 11:05:01
问题 I've followed the instructions here and succesfully set up a UITextField that gets updated with a UIDatePicker. However the cursor in the UITextField is blinking, which seems quite a bit awkward to me. Is there any solution to get rid of that cursor? 回答1: I realise this is an old question, but with the updates to iOS 7, it is now possible to hide the cursor by doing the following: [[self textFieldName] setTintColor:[UIColor clearColor]]; It will only work on iOS 7+ however. 回答2: Subclass

keyboard in UIActionSheet does not type anything

守給你的承諾、 提交于 2019-11-30 10:58:16
I'm wondering why my iPhone keyboard opened by a UITextField doesn't type anything except the delete key and the clear button within the text field itself. The text field is embedded in a UIActionSheet with this code sample: // setup UITextField for the UIActionSheet UITextField* textField = [[UITextField alloc] initWithFrame:CGRectMake(8.0, 34.0, 304.0, 30.0)]; NSString* startText = [[self.pathName lastPathComponent] stringByDeletingPathExtension]; textField.borderStyle = UITextBorderStyleRoundedRect; textField.backgroundColor = [UIColor whiteColor]; textField.clearButtonMode =

Where can I get the magnifying glass icon used in UISearchBar?

☆樱花仙子☆ 提交于 2019-11-30 09:26:20
I'm using UITextField as a UISearchBar replacement and "stealing" the magnifying glass icon from the original UISearchBar with this crazy code: UISearchBar *originalSearchBar = [[UISearchBar alloc] init]; for (UIView *searchBarSubview in [originalSearchBar subviews]) { if([searchBarSubview isKindOfClass:[UITextField class]]) { UITextField *textField = (UITextField *)searchBarSubview; [_textField setLeftView:[textField leftView]]; [_textField setLeftViewMode:UITextFieldViewModeAlways]; } } As you've probably guessed, I don't want to use my own bitmap. Isn't there an easier accessible magnifying

Incorrect number of objects getting added to mutable array

送分小仙女□ 提交于 2019-11-30 09:23:45
问题 I have a view controller with table view that contains 8 cells(sections).I have created a textField and added that text field as a subview to 6 cells,remaining 2 cells of which one cell contains a text view and the other with a button.Because I am using the same text field,I have assigned tag values and then created a mutable array,added the textfield to that array.Here is the implementation code: Taking in regard the suggestion given by Mr.Lanc,I have changed the implementation code EDIT -

UITextField clearButtonMode color

扶醉桌前 提交于 2019-11-30 08:44:19
can I change the color of the clearButtonMode on a textField? theTextField.clearButtonMode = UITextFieldViewModeWhileEditing shows an x that is grey dark color to delete the textField, but can i show this button with white color? thanks Ben Harris You'll need to create your own clear button image in this case. I would suggest taking a screenshot of the clear button and editing in photoshop. You can take that image and create a UIButton with the image dimensions. From there you can set it as the UITextField's rightView. Like so: UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];

Change UITextField's placeholder text color programmatically

∥☆過路亽.° 提交于 2019-11-30 08:43:59
I have a UITextField with a placeholder. When the user wants to submit the form and he/she hasn't typed anything in the textfield, I would like the placeholder's text color become red. Here are my questions: Would that go against Apple's User interface guidelines? I don't want my app to be rejected because of such small detail. How I would do it? I know I can override the method drawPlaceholderInRect: in a subclass of UITextField . But if I did this, the text would be always red and as I wrote before, I would like it to become red depending on a user defined action. The only solution I can

How to make UITableview with Textfield in swift?

流过昼夜 提交于 2019-11-30 08:38:33
I want to make a table view with textfields in each cell, I have a custom class in a swift file: import UIKit public class TextInputTableViewCell: UITableViewCell{ @IBOutlet weak var textField: UITextField! public func configure(#text: String?, placeholder: String) { textField.text = text textField.placeholder = placeholder textField.accessibilityValue = text textField.accessibilityLabel = placeholder } } Then in my ViewController I have func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell{ let cell = tableView

Secure UITextField text change to (*) asterisk character

不羁岁月 提交于 2019-11-30 08:26:42
How can I change a secure UITextField text (which is simply a bunch of dots) to (*) asterisk characters like in the image below? Anupdas You can set it programmatically by [textField setSecureTextEntry:YES]; or in IB (secured checkbox at the bottom) You could also try simply implementing your own "secure text field". Simply create a normal, non-secure text field, and link it's "Editing Changed" action with a method in your view controller. Then within that method you can take the new characters every time the text is changed, and add them to a private NSString property, and then set the