1. 程式人生 > >iOS登入介面和註冊介面

iOS登入介面和註冊介面

- (void)addLoginBackgroundView:(CGRect)frame{
   
CGFloat backgroundX = 30;
   
CGFloat backgroundY = 160;
   
CGFloat backgroundW = frame.size.width - 60;
   
CGFloat backgroundH = 80;
   
self.backgroundView = [[LoginBackgroundView alloc] initWithFrame:CGRectMake(backgroundX, backgroundY, backgroundW, backgroundH)];
    [
self.backgroundView setBackgroundColor:[UIColor whiteColor]];
    [
self.backgroundView.layer setCornerRadius:5.0];
    [
self.backgroundView.layer setBorderWidth:1.0];
    [
self.backgroundView.layer setBorderColor:textFieldColor(207, 207, 207).CGColor];
    [
self addSubview:self.backgroundView];
}

- (
void
)customAllButtons:(CGRect)frame{
   
//返回button UIButton *backButton = [[UIButton alloc] initWithFrame:CGRectMake(19, 35, 22, 22)];
    [backButton
setBackgroundImage:[UIImage imageNamed:@"back"] forState:UIControlStateNormal];
    [backButton
addTarget:self action:@selector(clickTheBackButton:) forControlEvents
:UIControlEventTouchDown];
    [
self addSubview:backButton];
   
//登入button CGFloat loginButtonX = 30;
   
CGFloat loginButtonY = 250;
   
CGFloat loginButtonW = frame.size.width - 60;
   
self.loginButton = [[UIButton alloc] initWithFrame:CGRectMake(loginButtonX, loginButtonY, loginButtonW, 40)];
    [
self.loginButton setEnabled:NO];
   
self.loginButton.titleLabel.alpha = 0.5;
    [
self.loginButton.layer setCornerRadius:3.0];
    [
self.loginButton setTitle:@"登入" forState:UIControlStateNormal];
    [
self.loginButton setTitleColor:[UIColor whiteColor] forState:UIControlStateReserved];
    [
self.loginButton setBackgroundColor:mianBodyColor(133, 122, 250)];
    [
self.loginButton addTarget:self action:@selector(clickLoginButton:) forControlEvents:UIControlEventTouchDown];
    [
self addSubview:self.loginButton];
   
//忘記密碼 CGFloat forgetButtonW = 73;
   
CGFloat forgetButtonX = loginButtonX + loginButtonW - forgetButtonW;
   
CGFloat forgetButtonY = 0.916 * (loginButtonY + 100);
   
CGFloat forgetButtonH = 20;
   
UIButton *forgetButton = [[UIButton alloc] initWithFrame:CGRectMake(forgetButtonX, forgetButtonY, forgetButtonW, forgetButtonH)];
    [forgetButton
addTarget:self action:@selector(clickForgetpasswordTextFieldButton:) forControlEvents:UIControlEventTouchDown];
    [forgetButton
setTitle:@"忘記密碼?" forState:UIControlStateNormal];
    [forgetButton.
titleLabel setFont:[UIFont systemFontOfSize:14]];
    [forgetButton
setTitleColor:textFieldColor(74, 74, 74) forState:UIControlStateNormal];
    [
self addSubview:forgetButton];
}

- (
void)customUserTextField:(CGRect)frame{
   
self.userTextField = [[BasicTextField alloc] initWithFrame:CGRectMake(0, 0, frame.size.width, 40)];
   
self.userTextField.keyboardType = UIKeyboardTypeNumberPad;
   
self.userTextField.delegate = self;
   
self.userTextField.tag = 7;
   
self.userTextField.placeholder = @"請輸入賬號";
    [
self.userTextField setFont:[UIFont systemFontOfSize:14]];
   
UIImageView *userTextFieldImage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"userIcon"]];
   
self.userTextField.leftView = userTextFieldImage;
   
self.userTextField.leftViewMode = UITextFieldViewModeAlways;
   
self.userTextField.clearButtonMode = UITextFieldViewModeAlways;
    [[
NSNotificationCenter defaultCenter] addObserver:self selector:@selector(userTextFieldDidChange) name:UITextFieldTextDidChangeNotification object:self.userTextField];
   
self.isPasswordEmpty = YES;
    [
self.backgroundView addSubview:self.userTextField];
}

- (
void)customPasswordTextField:(CGRect)frame{
   
self.passwordTextField = [[BasicTextField alloc] initWithFrame:CGRectMake(0, 40, frame.size.width, 40)];
   
self.passwordTextField.delegate = self;
   
self.passwordTextField.tag = 11;
   
self.passwordTextField.placeholder = @"請輸入密碼";
    [
self.passwordTextField setFont:[UIFont systemFontOfSize:14]];
   
UIImageView *passwordTextFieldImage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"passwordIcon"]];
   
self.passwordTextField.leftView = passwordTextFieldImage;
   
self.passwordTextField.leftViewMode = UITextFieldViewModeAlways;
   
self.passwordTextField.clearButtonMode = UITextFieldViewModeAlways;