您的位置:首页 > 产品设计 > UI/UE

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];
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: