Created
January 24, 2017 18:58
-
-
Save JMatharu/12b79ba26241e7be25a59c3a8c9bde21 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// LoginRegisterViewController.m | |
// CookBook | |
// | |
// Created by Jagdeep Matharu on 2017-01-23. | |
// Copyright © 2017 Jagdeep Matharu. All rights reserved. | |
// | |
#import "LoginRegisterViewController.h" | |
@interface LoginRegisterViewController () | |
@end | |
@implementation LoginRegisterViewController | |
- (void)viewDidLoad { | |
[super viewDidLoad]; | |
//set the background color of the view | |
self.view.backgroundColor = [UIColor colorWithRed:61.0/255.0 green:91.0/255.0 blue:151.0/255.0 alpha:1]; | |
//center Container | |
[self createInputContainerView]; | |
//Register Button | |
[self createLoginRegisterButton]; | |
// [self createNameTextField]; | |
} | |
- (UIView *) createInputContainerView { | |
UIView *centerContainer = [[UIView alloc] init]; | |
centerContainer.backgroundColor = [UIColor whiteColor]; | |
[centerContainer setTranslatesAutoresizingMaskIntoConstraints:false]; | |
centerContainer.layer.cornerRadius = 5; | |
centerContainer.layer.masksToBounds = true; | |
[self.view addSubview:centerContainer]; | |
[centerContainer.centerXAnchor constraintEqualToAnchor:self.view.centerXAnchor].active = true; | |
[centerContainer.centerYAnchor constraintEqualToAnchor:self.view.centerYAnchor].active = true; | |
[centerContainer.widthAnchor constraintEqualToAnchor:self.view.widthAnchor constant:-24].active = true; | |
[centerContainer.heightAnchor constraintEqualToConstant:150].active = true; | |
[centerContainer addSubview:[self createNameTextField]]; | |
[[self createNameTextField].leftAnchor constraintEqualToAnchor:centerContainer.leftAnchor constant:12].active = true; | |
[[self createNameTextField].topAnchor constraintEqualToAnchor:centerContainer.topAnchor].active = true; | |
[[self createNameTextField].widthAnchor constraintEqualToAnchor:centerContainer.widthAnchor].active = true; | |
[[self createNameTextField].heightAnchor constraintEqualToAnchor:centerContainer.heightAnchor multiplier:1/3].active = true; | |
return centerContainer; | |
} | |
- (UIButton *) createLoginRegisterButton { | |
UIButton *button = [[UIButton alloc] init]; | |
button.backgroundColor = [UIColor colorWithRed:91.0/255.0 green:115.0/255.0 blue:169.0/255.0 alpha:1]; | |
[button setTitleColor:[UIColor whiteColor] forState:normal]; | |
[button setTitle:@"Register" forState:normal]; | |
[button setTranslatesAutoresizingMaskIntoConstraints:false]; | |
[self.view addSubview:button]; | |
[button.centerXAnchor constraintEqualToAnchor:self.view.centerXAnchor].active = true; | |
[button.topAnchor constraintEqualToAnchor:[self createInputContainerView].bottomAnchor constant:12].active = true; | |
[button.widthAnchor constraintEqualToAnchor:[self createInputContainerView].widthAnchor].active = true; | |
[button.heightAnchor constraintEqualToConstant:50].active = true; | |
return button; | |
} | |
- (UITextField *) createNameTextField { | |
UITextField *tfName = [[UITextField alloc] init]; | |
tfName.placeholder = @"Name"; | |
tfName.translatesAutoresizingMaskIntoConstraints = false; | |
return tfName; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment