UI 03 UITextField
2015-08-03 08:50
417 查看
UITextField 继承于 UIControl .
特殊的技能是可以输入.
下面的方法是:
特殊的技能是可以输入.
// 输入框 UITextField *textField = [[UITextField alloc] initWithFrame:CGRectMake(100, 50, 200, 40)]; textField.backgroundColor = [UIColor whiteColor]; [self.window addSubview:textField]; [textField release]; textField.layer.borderWidth = 1; textField.layer.cornerRadius = 10; // 初始文本 //textField.text = @"贱男"; textField.textColor = [UIColor purpleColor]; // 占位文本 textField.placeholder = @"请输入姓名"; textField.textAlignment = NSTextAlignmentCenter; textField.keyboardType = UIKeyboardTypeDefault; // return 按钮切换样式 textField.returnKeyType = UIReturnKeyDone; textField.clearsOnBeginEditing = YES; //textField.secureTextEntry = YES; // 清除按钮的样式 textField.clearButtonMode = UITextFieldViewModeAlways; // 创建一个view UIView *view = [[UIView alloc] initWithFrame:CGRectMake(100, 100, 20, 20)]; view.backgroundColor = [UIColor orangeColor]; // 弹出一个自定义的视图,默认是键盘 textField.inputView = view; // 给键盘添加一个辅助视图. textField.inputAccessoryView = view; // 给textfield设置代理人. textField.delegate = self; // 点击Return 按钮,回收键盘.(协议)
下面的方法是:
// 实现协议方法 - (BOOL)textFieldShouldReturn:(UITextField *)textField{ NSLog(@"测试return按钮"); NSLog(@"%@",textField.text); // 这句话是回收return键盘 [textField resignFirstResponder]; return YES; } - (BOOL)textFieldShouldClear:(UITextField *)textField{ NSLog(@"测试清除按钮"); return YES; } // UITextField 继承于UIControl 所以也有这个点击方法. - (void)click:(UITextField *)textField{ }
相关文章推荐
- UI 02 UIButton
- iOS UI03_登陆+注册 UI1~3系统归纳
- UIViewController视图控制器(移动self.view,随机颜色)
- UIImageView图片填充三种模式的区别
- HackerRank - "Snakes and Ladders: The Quickest Way Up"
- 为什么不推荐用UniversalImageLoader加载res/drawable
- UE4信息交互-关卡蓝图引用关卡中的对象
- wildfly使用入门
- IOS开发UI篇--IOS动画(Core Animation)总结
- 本教程针对HBuilder5.0.0,制作日期2014-12-31(从HBuilder工具上获得)
- UE4信息交互-命令行执行自定义事件ConsoleCommand
- 本教程针对HBuilder5.0.0,制作日期2014-12-31(从HBuilder工具上获得)
- [leedcode 187] Repeated DNA Sequences
- leetcode 63: Unique Paths II
- iOS开发——UI进阶篇(十三)UITabBarController简单使用,qq主流框架
- hdu 5312 Sequence
- php图像函数 imagecreatetruecolor()和imagecreate()的区别
- 关于Android Notification.Builder不显示通知的问题
- iOS学习笔记5-GCDAsyncUdpSocket中的dispatch_queue_set_specific
- iOS多线程编程之NSOperation和NSOperationQueue的使用