您的位置:首页 > 职场人生

黑马程序员——iOS 开发学习---登录注册页面跳转

2016-01-11 10:39 776 查看
——Java培训、Android培训、iOS培训、.Net培训、期待与您交流! ——-

.h

{
UIView *_view;
UIView *image2;
UITextField *_text;
UITextField *_enter;
UITextField *_registered;
UIButton *_button3;
}


.m

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];

_view=[[UIView alloc]initWithFrame:CGRectMake(0, 0, 320, 480)];
_view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"1.png"]];
[self.window addSubview:_view];

image2=[[UIView alloc]initWithFrame:CGRectMake(0, 0, 320, 480)];
image2.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"2.jpg"]];

_enter=[[UITextField alloc]initWithFrame:CGRectMake(80, 110, 170, 30)];
_enter.backgroundColor=[UIColor grayColor];
_enter.placeholder=@"密码:";
_enter.textColor=[UIColor blackColor];
_enter.secureTextEntry=YES;//输入安全
_enter.clearButtonMode=YES;//出现小叉,点击消除输入框所有文字
[_view addSubview:_enter];

_registered=[[UITextField alloc]initWithFrame:CGRectMake(80, 70, 170, 30)];
_registered.backgroundColor=[UIColor grayColor];
_registered.placeholder=@"账号:";
_registered.textColor=[UIColor blackColor];
_registered.clearButtonMode=YES;
[_view addSubview:_registered];

for (int i=0; i<=6; i++) {
_text=[[UITextField alloc]initWithFrame:CGRectMake(80, 35+50*i, 200, 40)];
_text.backgroundColor=[UIColor grayColor];
_text.clearButtonMode=YES;
//[_textField becomeFirstResponder];
[image2 addSubview:_text];
}
for (int i=0; i<=6; i++) {
UILabel *lable=[[UILabel alloc]initWithFrame:CGRectMake(10, 35+50*i, 60, 40)];
lable.backgroundColor=[UIColor grayColor];
lable.text=@".0.0.";
[image2 addSubview:lable];
}

UIButton *button1=[UIButton buttonWithType:UIButtonTypeCustom];
button1.frame=CGRectMake(50, 350, 80, 30);
button1.showsTouchWhenHighlighted=YES;
button1.backgroundColor=[UIColor grayColor];
[button1 setTitle:@"登陆" forState:UIControlStateNormal];
[button1 setTitleColor:[UIColor blueColor] forState:UIControlStateHighlighted];
[_view addSubview:button1];

UIButton *button2=[UIButton buttonWithType:UIButtonTypeCustom];
button2.frame=CGRectMake(320-(50+80), 350, 80, 30);
button2.showsTouchWhenHighlighted=YES;
button2.userInteractionEnabled=YES;
button2.backgroundColor=[UIColor grayColor];
[button2 setTitle:@"注册" forState:UIControlStateNormal];
[button2 setTitleColor:[UIColor blueColor] forState:UIControlStateHighlighted];
[button2 addTarget:self action:@selector(registered) forControlEvents:UIControlEventTouchDown];
[_view addSubview:button2];

_button3=[UIButton buttonWithType:UIButtonTypeCustom];
_button3.frame=CGRectMake(110, 400, 100, 30);
_button3.showsTouchWhenHighlighted=YES;
_button3.userInteractionEnabled=YES;
_button3.backgroundColor=[UIColor grayColor];
[_button3 setTitle:@"返回登陆页" forState:UIControlStateNormal];
[_button3 setTitleColor:[UIColor blueColor] forState:UIControlStateHighlighted];
[_button3 addTarget:self action:@selector(back) forControlEvents:UIControlEventTouchDown];
[image2 addSubview:_button3];

return YES;
}

-(void)registered
{
[_view canBecomeFirstResponder];
[self.window addSubview:image2];
}
-(void)back
{
[image2 canBecomeFirstResponder];
[self.window addSubview:_view];

}

//消除键盘
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
[_enter resignFirstResponder];
[_registered resignFirstResponder];
//   [_text resignFirstResponder];
[self.window endEditing:YES];
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: