IOS_TextField,UIButton
2015-09-05 11:50
405 查看
一 :
TextField:
//单行文本输入框
UITextField *username = [[UITextField
alloc] initWithFrame:CGRectMake(10,
50, 210,
30)];
username.backgroundColor = [UIColor
whiteColor];
[self.window
addSubview:username];
username.borderStyle =
UITextBorderStyleRoundedRect;
username.placeholder =
@"请输入用户名";
username.textAlignment =
NSTextAlignmentCenter;
[username
release];
//多行输入
UITextField *username1 = [[UITextField
alloc] initWithFrame:CGRectMake(10,
140, 210,
60)];
username1.backgroundColor = [UIColor
redColor];
[self.window
addSubview:username1];
// username1.clearButtonMode = UITextBorderStyleRoundedRect;
//加密输入
// username.secureTextEntry = YES;
username1.keyboardType =
UIKeyboardTypeURL;
二 :
Button:
//UIButton
UIButton *button = [UIButton
buttonWithType:UIButtonTypeSystem];
//title
button.frame =
CGRectMake(80,
370, 100,
30);
button.backgroundColor = [UIColor
yellowColor];
[self.window
addSubview:button];
//给button添加标题
[button setTitle:@"title"
forState:UIControlStateNormal];
//点击的时候有高亮状态
button.showsTouchWhenHighlighted =
YES;
// 给button指定一个功能方法
//参数1 :点击按钮之后,让什么对象调用方法(self指当前类的对象)
//参数2 :让参数1的对象调用方法(写方法名:)
//参数3 :
[button addTarget:self
action:@selector(buttonAction:)
forControlEvents:UIControlEventTouchUpInside];
// [button setTitle:@"注册" forState:UIControlStateNormal];
// [button addTarget:self action:@selector(bu) forControlEvents:UIControlEventTouchUpInside];
//按钮点击方法的写法格式
//- (void)方法名 :(UIButton *)btn
-(void) buttonAction:(UIButton *)btn
{
NSLog(@"点击");
self.window.backgroundColor = [UIColor
blackColor];
}
TextField:
//单行文本输入框
UITextField *username = [[UITextField
alloc] initWithFrame:CGRectMake(10,
50, 210,
30)];
username.backgroundColor = [UIColor
whiteColor];
[self.window
addSubview:username];
username.borderStyle =
UITextBorderStyleRoundedRect;
username.placeholder =
@"请输入用户名";
username.textAlignment =
NSTextAlignmentCenter;
[username
release];
//多行输入
UITextField *username1 = [[UITextField
alloc] initWithFrame:CGRectMake(10,
140, 210,
60)];
username1.backgroundColor = [UIColor
redColor];
[self.window
addSubview:username1];
// username1.clearButtonMode = UITextBorderStyleRoundedRect;
//加密输入
// username.secureTextEntry = YES;
username1.keyboardType =
UIKeyboardTypeURL;
二 :
Button:
//UIButton
UIButton *button = [UIButton
buttonWithType:UIButtonTypeSystem];
//title
button.frame =
CGRectMake(80,
370, 100,
30);
button.backgroundColor = [UIColor
yellowColor];
[self.window
addSubview:button];
//给button添加标题
[button setTitle:@"title"
forState:UIControlStateNormal];
//点击的时候有高亮状态
button.showsTouchWhenHighlighted =
YES;
// 给button指定一个功能方法
//参数1 :点击按钮之后,让什么对象调用方法(self指当前类的对象)
//参数2 :让参数1的对象调用方法(写方法名:)
//参数3 :
[button addTarget:self
action:@selector(buttonAction:)
forControlEvents:UIControlEventTouchUpInside];
// [button setTitle:@"注册" forState:UIControlStateNormal];
// [button addTarget:self action:@selector(bu) forControlEvents:UIControlEventTouchUpInside];
//按钮点击方法的写法格式
//- (void)方法名 :(UIButton *)btn
-(void) buttonAction:(UIButton *)btn
{
NSLog(@"点击");
self.window.backgroundColor = [UIColor
blackColor];
}
相关文章推荐
- IOS_UI_Label
- mysql 插入中文时出现ERROR 1366 (HY000): Incorrect string value: '\xC0\xEE\xCB\xC4' for column 'usern ame' at row 1
- Android UI设计:ViewFlipper使图片循环滑动
- iOS 关于UICollectionView的cell重用问题
- GCC内建函数 __builtin_return_address实现
- hdu 1121 Complete the Sequence(插值差分)
- 关于divide and conquer的两道Leetcode
- HDU1711 Number Sequence(KMP模版题)
- parseInt和valueOf
- Lexical or preprocessor 'XXX/XXX.h' issue file not found
- POJ2299 Ultra-QuickSort(树状数组求逆序数+离散化)
- ueditor样式过滤问题
- UIday0803:UIDatePicker的属性和用法
- UIday0802:UINavigationController 传值(界面通信)
- UIDatePicker
- stack && queue && priority_queue 使用方法 (栈, 队列, 优先队列)
- leetcode_Unique Binary Search Trees_easy
- 【UI初级 连载四】--------UI常用控件
- uetitor上传图片及附件问题
- UI连载十-----------表视图单元格定制