UI_UITextField
来源:互联网 发布:java代码换行 编辑:程序博客网 时间:2024/06/06 09:58
UITextField
AppDelegate.h
#import <UIKit/UIKit.h>
@interface AppDelegate :UIResponder <UIApplicationDelegate,UITextFieldDelegate>
@property (strong,nonatomic) UIWindow *window;
@end
AppDelegate.m
#import "AppDelegate.h"
@interface AppDelegate ()
@end
@implementation AppDelegate
- (void)dealloc
{
[_window release];
[superdealloc];
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
self.window = [[UIWindowalloc] initWithFrame:[[UIScreenmainScreen] bounds]];
// Override point for customization after application launch.
self.window.backgroundColor = [UIColorwhiteColor];
[self.windowmakeKeyAndVisible];
//创建TextField
UITextField *textField1 = [[UITextFieldalloc] initWithFrame:CGRectMake(120, 120, 180, 30)];
UILabel *nameLabel = [[UILabelalloc] initWithFrame:CGRectMake(60, 120, 40, 30)];
UIView *sssView = [[UIViewalloc] initWithFrame:CGRectMake(0, 0, 0, 10)];
sssView.backgroundColor = [UIColoryellowColor];
//⾃自定义输⼊入视图(默认是键盘)
// textField1.inputView = sssView;
// 输⼊视图上方的辅助视图(默认nil),要添加的辅助视图,可以不给宽度,但是必须要指定高度,宽度默认就是屏幕宽,可以弹广告
textField1.inputAccessoryView = sssView;
nameLabel.text =@"姓名:";
nameLabel.textAlignment =NSTextAlignmentRight;
textField1.text =@"king";
// textField1.placeholder = @"joker"; //用来展位,不是内容
// textField1.font = [UIFont systemFontOfSize:30];
//加粗,字体大小
// textField1.font = [UIFont fontWithName:@"Helvetica-Bold" size:20];
textField1.textAlignment =NSTextAlignmentLeft;
//textField1.textColor = [UIColor blueColor];
// 边框
textField1.layer.borderWidth = 1;
textField1.layer.cornerRadius = 5;
//是否在输入的时候清空里面的内容,针对的时text属性的内容,不使placeholder
// textField1.clearsOnBeginEditing = YES; //清空的是text的内容,不是placeholder
textField1.clearsOnBeginEditing =YES;
textField1.enabled =YES;//是否能进行输入
textField1.secureTextEntry =YES; //以密码的方式输入
// textField1.keyboardType = UIKeyboardTypeEmailAddress;//键盘类型
// textField1.returnKeyType = UIReturnKeySearch; //键盘右下⾓角return按钮类型(枚举值)
//输入框后边的x
textField1.clearButtonMode =UITextFieldViewModeAlways;
//设置代理人
textField1.delegate =self;
textField1.tag = 1000;//window的tag是0
[self.windowaddSubview:nameLabel];
[self.windowaddSubview:textField1];
[textField1release];
[nameLabelrelease];
// NSLog(@"%p",textField1);
[_window release];
return YES;
}
- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
//谁触发的协议方法,对应传过来的textField就是谁
// NSLog(@"%ld", textField.tag);
// NSLog(@"%@", textField.text);
// NSLog(@"%p",textField);
// textField.text = @"aaa";
[textField resignFirstResponder]; //点击return回收键盘
return YES;
}
- UI_UITextField
- Unreal Engine 4(UE4)下载教程
- VMware下网络配置三种模式对比(桥接模式,主机模式,网络地址转换)
- intent 启动模式(FLAG_ACTIVITY_CLEAR_TOP和FLAG_ACTIVITY_REORDER_TO_FRONT)
- 窗口滚动动画
- 积跬步至千里——算法强化训练(6)利用基数排序解决O(n)问题
- UI_UITextField
- iOS 结束编辑
- sgu230:Weighings(拓扑)
- 下载网络文件
- 网站开发人员应该知道的61件事
- C# Form控件的Focus()方法总返回false
- error C4996: 'avcodec_get_frame_defaults': 被声明为已否决
- Spring技巧之活用FactoryBean
- 图解SSL/TLS协议