Sunday, 29 September 2013

loginViewController.h

#import <UIKit/UIKit.h>
#import "HomeViewController.h"
#import "RegisterViewController.h"
#import "ForgotPasswordViewController.h"

@interface loginViewController : UIViewController
{
    UIButton *registerNewUserButton,*canotAccessAccountButton,*logInButton;

    UILabel *userNameLabel,*passwordLabel,*rememberMeSwitchLabel;
    UIImageView *backgroundImageView,*logoImageview;
    UIImage *backgroundImage,*logoImage;
    UISwitch *rememberMeSwitch;
}
@property(nonatomic,retain) UITextField *userNameTextField;
@property(nonatomic,retain) UITextField *passwordTextField;

-(void)loginDatasubmited;
-(void)remembermeSelected;
-(void)canotAccessMyAccount;
-(void)RegisterNewUser;
-(void)removeKeyBoard;


@end

loginViewController.m


#import "loginViewController.h"

@interface loginViewController ()

@end

@implementation loginViewController
@synthesize userNameTextField,passwordTextField;

- (void)viewDidLoad
{
    [super viewDidLoad];
    backgroundImage=[UIImage imageNamed:@"skyblue.jpg"];
    backgroundImageView=[[UIImageView alloc] initWithImage:backgroundImage];
    [backgroundImageView setFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
    [self.view addSubview:backgroundImageView];
    logoImage=[UIImage imageNamed:@"mylogo.png"];
    logoImageview=[[UIImageView alloc] initWithImage:logoImage];
    [logoImageview setFrame:CGRectMake(70, 20, 150, 50)];
    [self.view addSubview:logoImageview];
// Do any additional setup after loading the view, typically from a nib.
    registerNewUserButton=[UIButton buttonWithType:UIButtonTypeCustom];
    [registerNewUserButton setFrame:CGRectMake(100, 100, 200, 30)];
    [registerNewUserButton setBackgroundColor:[UIColor clearColor]];
    [registerNewUserButton setTitle:@"Register New User" forState:UIControlStateNormal];
    [registerNewUserButton setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
    [registerNewUserButton addTarget:self action:@selector(RegisterNewUser) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:registerNewUserButton];
    
    userNameLabel=[[UILabel alloc] initWithFrame:CGRectMake(40, 150, 250, 20)];
    [userNameLabel setBackgroundColor:[UIColor clearColor]];
    [userNameLabel setText:@"User Name"];
    //[FirstNameLabel setTextAlignment:NSTextAlignmentCenter];
    [userNameLabel setFont:[UIFont boldSystemFontOfSize:13]];
    [self.view addSubview:userNameLabel];
    
    
    userNameTextField=[[UITextField alloc] initWithFrame:CGRectMake(30, 172, 250, 30)];
    [userNameTextField setPlaceholder:@"Enter User Name"];
    [userNameTextField setBorderStyle:UITextBorderStyleRoundedRect];
    [userNameTextField setTextAlignment:NSTextAlignmentLeft];
    [userNameTextField setFont:[UIFont systemFontOfSize:14]];
    [userNameTextField setBackgroundColor:[UIColor whiteColor]];
    [userNameTextField addTarget:self action:@selector(removeKeyBoard) forControlEvents:UIControlEventEditingDidEndOnExit];
    [self.view addSubview:userNameTextField];
    
    
    passwordLabel=[[UILabel alloc] initWithFrame:CGRectMake(40, 215, 250, 20)];
    [passwordLabel setBackgroundColor:[UIColor clearColor]];
    [passwordLabel setText:@"Password"];
    //[FirstNameLabel setTextAlignment:NSTextAlignmentCenter];
    [passwordLabel setFont:[UIFont boldSystemFontOfSize:13]];
    [self.view addSubview:passwordLabel];
    
    
    passwordTextField=[[UITextField alloc] initWithFrame:CGRectMake(30, 240, 250, 30)];
    [passwordTextField setPlaceholder:@"Enter Password"];
    [passwordTextField setBorderStyle:UITextBorderStyleRoundedRect];
    [passwordTextField setTextAlignment:NSTextAlignmentLeft];
    [passwordTextField setFont:[UIFont systemFontOfSize:14]];
    [passwordTextField setBackgroundColor:[UIColor whiteColor]];
    [passwordTextField addTarget:self action:@selector(removeKeyBoard) forControlEvents:UIControlEventEditingDidEndOnExit];
    [self.view addSubview:passwordTextField];
    
    rememberMeSwitch=[[UISwitch alloc] initWithFrame:CGRectMake(40, 290, 60, 10)];
    [self.view addSubview:rememberMeSwitch];
    
    rememberMeSwitchLabel=[[UILabel alloc] initWithFrame:CGRectMake(120, 290, 150, 20)];
    [rememberMeSwitchLabel setBackgroundColor:[UIColor clearColor]];
    [rememberMeSwitchLabel setText:@"Remember Me"];
    [rememberMeSwitchLabel setTextColor:[UIColor greenColor]];
       //[FirstNameLabel setTextAlignment:NSTextAlignmentCenter];
    [rememberMeSwitchLabel setFont:[UIFont boldSystemFontOfSize:13]];
    [self.view addSubview:rememberMeSwitchLabel];
    
    
    
    logInButton=[UIButton buttonWithType:UIButtonTypeCustom];
    [logInButton setFrame:CGRectMake(100, 350, 80, 30)];
    [logInButton setTitle:@"LogIn" forState:UIControlStateNormal];
    [logInButton setBackgroundColor:[UIColor blueColor]];
    [logInButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [logInButton addTarget:self action:@selector(loginDatasubmited) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:logInButton];
    
    
    canotAccessAccountButton=[UIButton buttonWithType:UIButtonTypeCustom];
    [canotAccessAccountButton setFrame:CGRectMake(10,410,250,30)];
    [canotAccessAccountButton setBackgroundColor:[UIColor clearColor]];
    [canotAccessAccountButton setTitle:@"Canot Access my account" forState:UIControlStateNormal];
    [canotAccessAccountButton setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
    [canotAccessAccountButton addTarget:self action:@selector(canotAccessMyAccount) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:canotAccessAccountButton];  

      self.title=@"Log IN";


    
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
-(void)loginDatasubmited{
   
    HomeViewController *objHome=[[HomeViewController alloc] init];
    [self.navigationController pushViewController:objHome animated:YES];
    
    


}
-(void)remembermeSelected{




}
-(void)canotAccessMyAccount{
    
    ForgotPasswordViewController *objForgotPassword=[[ForgotPasswordViewController alloc] init];
    [self.navigationController pushViewController:objForgotPassword animated:YES];
    


}
-(void)RegisterNewUser{
    
    RegisterViewController *objreg=[[RegisterViewController alloc] init];
    [self.navigationController pushViewController:objreg animated:YES];


}

-(void)removeKeyBoard{
    [userNameTextField resignFirstResponder];
    [passwordTextField resignFirstResponder];

}

@end

No comments:

Post a Comment