uitextfield

Centering Placeholder Text in Subclass of UITextField

我与影子孤独终老i 提交于 2019-12-05 10:24:42
So first, I needed to set the placeholder text color, so I subclassed the UITextfield as shown in several stack overflow posts. This works fine. Here is an example post of this: How do I subclass UITextField and override drawPlaceholderInRect to change Placeholder color . But, when I try to use searchNameField.textAlignment = UITextAlignmentCenter; It is no longer centering the placeholder. The input text is still centered fine. So then, assuming that the centering is not working because of the subclassing, what do I have to add to my UITextField subclass in order to have the placeholder text

How to set the color of the place holder text for a UITextField while preserving its existing properties?

走远了吗. 提交于 2019-12-05 09:53:44
问题 I have seen some answers that show how to change the placeHolder text color for UITextField by overriding the drawPlaceholderInRect: method such as this one: iPhone UITextField - Change placeholder text color but that does not maintain the existing attributes such as alignment, font, etc...what is a better way to solve this? 回答1: From iOS 6, Without any subclassing, one can accomplish this with a couple lines of code like so: UIColor *color = [UIColor blackColor]; textField

Dotted / Dashed border for UITextView / UITextField

故事扮演 提交于 2019-12-05 09:44:25
I want to set a Dotted / Dashed border for my UITextField and UITextView . How can I do that? I know that, I can set border with this line of code: [self.textFieldCardTitle.layer setBorderWidth:1.0]; [self.textFieldCardTitle.layer setBorderColor:[[UIColor whiteColor] CGColor]]; Notice: I already have the idea to add a UIImageView behind the UITextView and set there an image with dashed border. But I don't want to solve it that way. You could try, for example, next approach: 1) Create image that will represent your border (for example: one dot and space) 2) Add image to project. 3) Set border

Invalid context 0x0 on UITextField (Xcode 5)

廉价感情. 提交于 2019-12-05 09:38:36
I am using a UITextField in my app. I am using [texfield becomeFirstResponder] . This works just fine and loads the keyboard when the view is loaded. However, this error comes up when I click on the UITextField again after it has been brought up. I don't understand exactly why, but here is the output I am getting: CGContextSetFillColorWithColor: invalid context 0x0. CGContextSetStrokeColorWithColor: invalid context 0x0. CGContextSaveGState: invalid context 0x0. CGContextSetFlatness: invalid context 0x0. CGContextAddPath: invalid context 0x0. CGContextDrawPath: invalid context 0x0.

How to write a Custom UItextField Class

China☆狼群 提交于 2019-12-05 08:56:43
In my app, i need to use a lot of textfields and i don't really want that every viewcontroller class contains the delegates of textfields which could be messy, I just want to create a generic class where it takes care of the delegate of textfields and returns me a text field where i can add it as a subview where ever i need. I want to make it as a library and call the class whenever i need a textfield FOR example CustomTexTField *textField = [[CustomTextField alloc] initWithFrame:Frame]; // returns a textField whose delegate will be set to CustomTextField // // all i should do is just adding

Animating UITextInput's textInputView

情到浓时终转凉″ 提交于 2019-12-05 07:53:14
UIKit text input components, such as UITextView and UITextField have a property inputView to add a custom keyboard. There are two questions I have relating to this. If the keyboard is currently visible and the property is set to a new input view, nothing happens. Resigning and regaining first responder status refreshes the input and displays the new view. Is this the best way to do it? If so it might answer my bigger question: Is it possible to animate the transition between two input views? From the UIResponder docs: Responder objects that require a custom view to gather input from the user

Adjust width of UITextField to fill toolbar in landscape

被刻印的时光 ゝ 提交于 2019-12-05 07:25:36
In a UIToolbar , I have added a UITextField to the middle of the bar (which gets added as a UIBarButtonItem ) with another UIBarButtonItem (Action button) next to it. I added flexible space bar button items at the very left and very right. It looks great on portrait, but when I rotate to landscape it centers them and looks ok, but I need the text field to get stretched to fill the width and push the last button clear to the right - exactly like it does in Messages - on iPhone and iPad. I thought Auto Layout would do the trick but Apple states you cannot create constraints for UIBarButtonItem s

UITextField input text position [duplicate]

拟墨画扇 提交于 2019-12-05 06:33:33
问题 This question already has answers here : Set padding for UITextField with UITextBorderStyleNone (32 answers) Closed 6 years ago . Hello I'm making a custom UITextField like so : _textField.borderStyle=UITextBorderStyleNone; _textField.backgroundColor = _color; _textField.layer.borderColor = [[UIColor grayColor]CGColor]; _textField.layer.borderWidth = 1.0f; _textField.layer.cornerRadius = 8.0f; _textField.font = [UIFont systemFontOfSize:14]; The result I get is (image url) http://img402

How to get UITableViewCell's index from its edited UITextField

情到浓时终转凉″ 提交于 2019-12-05 06:27:55
I'm working on an iPhone based BI project. I have a UITextField in a UITextViewCell , the UITextFieldDelegate points to my UITableViewController , I haven't done any sub-classing for the UITextViewCell nor the UITextField . Now after the text field end editing on the delegate -(void)textFieldDidEndEditing:(UITextField*)textField I need to know the row index of the current cell I'm editing, is there any way to get the parent cell of the text field? Or can I set some property to the textfield like 'rowIndex' when I create the cell? I really need this value inorderto save the new text. Thank you.

Replacing UITextField input with a UIDatePicker

百般思念 提交于 2019-12-05 06:00:49
I have a table view controller with (among others) a cell that is to represent a date. I followed this post " How do I make a modal date picker that only covers half the screen? " and I have it working with one big exception - I can't get the picker to disappear! I tried registering for the event UIControlEventTouchUpOutside, but it seems that this is not generated by the picker (or at least in the mode that I am using it). How can I recognize that the user has finished selecting a date? Also, is there a way to disable the user from inputting directly into the UITextField? I want to force them