uitextfield

UITextField的文本插入?

泄露秘密 提交于 2020-02-26 00:10:03
我想插入一个 UITextField 的 文本 。 这可能吗? #1楼 使用 textRectForBounds: 是正确的方法。 我将其包装在子类中,因此您可以简单地使用 textEdgeInsets 。 参见 SSTextField 。 #2楼 我能够通过以下方式做到这一点: myTextField.layer.sublayerTransform = CATransform3DMakeTranslation(5, 0, 0); 当然,请记住导入QuartzCore并将框架添加到您的项目中。 #3楼 如果只需要左边距,则可以尝试以下操作: UItextField *textField = [[UITextField alloc] initWithFrame:...]; UIView *leftView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 10, textField.frame.size.height)]; leftView.backgroundColor = textField.backgroundColor; textField.leftView = leftView; textField.leftViewMode = UITextFieldViewModeAlways; 这个对我有用。 希望对您有所帮助。 #4楼

Padding Placeholder text ios

浪子不回头ぞ 提交于 2020-02-23 10:21:15
问题 I want to make the placeholder text display in middle of the textfield (Padding placeholder text). The size of the placeholder text also needs to increase. My code is as follows, how can i solve this ? UITextField *textField = [[UITextField alloc] initWithFrame:CGRectMake(30, 220,250,55)]; textField.placeholder=@"iiiiiii"; UIView *padView = [[UIView alloc] initWithFrame:CGRectMake(10, 110, 10, 0)]; textField.leftView = padView; textField.leftViewMode = UITextFieldViewModeAlways; [self.view

iOS基础UI控件介绍-Swift版

血红的双手。 提交于 2020-02-07 10:04:45
iOS基础UI控件总结 需要查看ObjectC版本的同学可以使用传送门: iOS基本UI控件总结-ObjectC版 iOS基础控件包括以下几类: 1、继承自NSObject:(暂列为控件) UIColor //颜色 UIImage //图像 2、继承自UIView: 只能相应手势UIGestureRecognizer事件,如果本身不响应会将事件action向superview传递 UILabel   //文本展示 UIImageView //图像展示 UIAlertController //提醒对话框(UIAlertView已被苹果官方弃用) UIScrollView    //滚动视图 UIProgressView //进度条 UIActivityIndicatorView //指示器 3、继承自UIControl: 可以监听手势UIGestureRecognizer事件和UIControlEvents事件,且不会将事件向superView传递 UIButton //按钮   UISwitch //选择按钮 UISlider //滑动条 UITextField   //文本框 UIStepper //数字递变控件(iOS5以后支持) UISegmentedControl //分段控件 基础介绍和常用第三方组件 以下第三方控件选择的都是用Swfit编写的

How to set position of an icon added in UITextField?

戏子无情 提交于 2020-02-05 08:14:26
问题 The email icon and placeholder text are hugging each other. I want to add some space between them. Below is the code I am using to create these fields. // view for fields background var view = UIView(frame: CGRectMake(35, 300, 300, 90)); view.backgroundColor = UIColor.whiteColor(); view.layer.cornerRadius = 5.0 // email text field var email = UITextField(frame: CGRectMake(0, 0, 300, 50)); email.backgroundColor = UIColor.whiteColor(); var emailIcon = UIImageView(); var emailIconImage = UIImage

How to set position of an icon added in UITextField?

China☆狼群 提交于 2020-02-05 08:12:41
问题 The email icon and placeholder text are hugging each other. I want to add some space between them. Below is the code I am using to create these fields. // view for fields background var view = UIView(frame: CGRectMake(35, 300, 300, 90)); view.backgroundColor = UIColor.whiteColor(); view.layer.cornerRadius = 5.0 // email text field var email = UITextField(frame: CGRectMake(0, 0, 300, 50)); email.backgroundColor = UIColor.whiteColor(); var emailIcon = UIImageView(); var emailIconImage = UIImage

UITextField delegate jumping to 100% CPU usage and crashing upon using keyboard shortcut

懵懂的女人 提交于 2020-01-29 04:40:26
问题 So, I have a UITextField subclass which is it's own Delegate and is crashing when keyboard shortcuts are used. It maxes out on CPU and doesn't give an error. Without assigning itself as it's Delegate , it works without problem. When it is assigned as it's Delegate , it crashes even when using none of the (optional) methods. Try it yourself: Subclass UITextField . - (id)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; if (self) { self.delegate = self; } return self; } It

UITextField - Keyboard not hiding when app comes from background

僤鯓⒐⒋嵵緔 提交于 2020-01-25 10:25:06
问题 In my iOS app, I've UITextfield at the bottom of the view. So, when user starts entering text, I'm sliding the view up so that users can see what they are typing. While entering text, view moves upwards, then press home button and the app goes to background. Now tap on the icon of the app and it brings the app to foreground Now I noticed that view comes back to original position (X=0, Y=0) but keyboard is still visible. How to hide the keyboard when the app comes to foreground. I tried to

Fill different UITextField with the same personalised keyboard

旧城冷巷雨未停 提交于 2020-01-25 08:44:25
问题 I've got a view where I've different UITextfield . To fil this TF I use a personalised UIPickerview as keyboard. My problem is, when I select the First TF the keyboard open and I can select my value. The value go to this selected TF. Now when I select the second TF the keyboard appears but the value goes to the first TF ... I don't know why this not works ... In my ViewDidLoad T've got : flightTimeSe.inputAccessoryView = Ttoolbar flightTimeSe.delegate = self flightTimeMe.inputView =

iOS: animating placeholder like material design textfield placeholder

荒凉一梦 提交于 2020-01-25 06:38:30
问题 I'm trying to make a textField that behaves just like the Material design MDCTextField . Everything is working well, but the animation of the placeholder is a bit buggy. The placeholder is going above the textField on editingDidBegin . But when returning the textField to its position on editingDidEnd , it is going below the textField then centered in the textField . What I want is to go back to the center of the textField without going below it. Knowing that the Placeholder is a UILabel. Here

UITextField placeholder text overlay issue

倾然丶 夕夏残阳落幕 提交于 2020-01-24 22:59:09
问题 I have a table view with three table view cells. During cell configuration, I add a UITextField to each of the cells and I also set the placeholder value on all of the text fields. When the table view loads the end results looks like this: The issue I'm having, is that when I scroll any of the cells "off the screen" when they reappear the placeholder text get darker and darker, like here: When I then attempt to change the UITextField string value by typing a name in, or by programatically