IOS -- xuer (regiuer), iosregistrationid
The logon page contains the adaptive screen size. The logon keyboard for a digital user is a digital keyboard, hidden keyboard, and hidden password.
ViewController. h
# Import <UIKit/UIKit. h> # import "UIViewExt. h "@ interface ViewController: UIViewController <UITextFieldDelegate>/*** background image */@ property (strong, nonatomic) UIImageView * Imagebackgroud; /*** username input box */@ property (strong, nonatomic) UITextField * NameTextfild;/*** password input box */@ property (strong, nonatomic) UITextField * PasswordTextfild; /*** logon button */@ property (strong, nonatomic) UIButton * LoginButton;/*** register button */@ property (strong, nonatomic) UIButton * RegistrationButton; @ end
ViewController. m
# Import "ViewController. h "# define WIDTH self. view. width # define HEIGHT self. view. height @ interface ViewController () @ end @ implementation ViewController-(void) viewDidLoad {[super viewDidLoad]; [self setBackgroudImage]; [self setLoginImage]; [self setTextFiled]; [self setButton] ;}# pragma Mark-method for setting the background image-(void) setBackgroudImage {self. imagebackgroud = [[UIImageView alloc] initWithFrame: self. view. frame]; [self. imagebackgroud setImage: [UIImage imageNamed: @ "beijing"]; [self. view addSubview: self. imagebackgroud] ;}# pragma Mark-set input box-(void) setTextFiled {// set self in the username input box. nameTextfild = [[UITextField alloc] initWithFrame: CGRectMake (WIDTH * 0.1, HEIGHT * 0.2, WIDTH * 0.8, HEIGHT * 0.05)]; self. nameTextfild. backgroundColor = [UIColor clearColor]; self. nameTextfild. placeholder = @ "Enter your mobile phone number"; // set the Input Keyboard to a numeric keyboard self. nameTextfild. keyboardType = UIKeyboardTypeNumberPad; // set the icon in the input box to not display self by default. nameTextfild. leftView = [[UIImageView alloc] initWithImage: [UIImage imageNamed: @ "phoneIcon"]; self. nameTextfild. leftViewMode = UITextFieldViewModeAlways; [self. view addSubview: self. nameTextfild]; // set the line UIView * Nameview = [[UIView alloc] initWithFrame: CGRectMake (WIDTH * 0.1, HEIGHT * 0.2 + HEIGHT * 0.05, WIDTH * 0.8, 1)]; Nameview. backgroundColor = [UIColor whiteColor]; [self. view addSubview: Nameview]; // set self in the password input box. passwordTextfild = [[UITextField alloc] initWithFrame: CGRectMake (WIDTH * 0.1, HEIGHT * 0.2 + HEIGHT * 0.06, WIDTH * 0.8, HEIGHT * 0.05)]; self. passwordTextfild. backgroundColor = [UIColor clearColor]; self. passwordTextfild. placeholder = @ "enter the password"; // set the password to protect (hide the password) self. passwordTextfild. secureTextEntry = YES; // you can click return to hide the proxy self on the keyboard. passwordTextfild. delegate = self; // set the icon in the input box to not display self by default. passwordTextfild. leftView = [[UIImageView alloc] initWithImage: [UIImage imageNamed: @ "passwordIcon"]; self. passwordTextfild. leftViewMode = UITextFieldViewModeAlways; [self. view addSubview: self. passwordTextfild]; // set the line UIView * Passwordview = [[UIView alloc] initWithFrame: CGRectMake (WIDTH * 0.1, HEIGHT * 0.31, WIDTH * 0.8, 1)] in the password input box; passwordview. backgroundColor = [UIColor whiteColor]; [self. view addSubview: Passwordview] ;}# pragma Mark-button setting method-(void) setButton {// set self for the logon button. loginButton = [[UIButton alloc] initWithFrame: CGRectMake (WIDTH * 0.1, HEIGHT * 0.35, WIDTH * 0.8, HEIGHT * 0.08)]; [self. loginButton setBackgroundImage: [UIImage imageNamed: @ "loginButton"] forState: UIControlStateNormal]; [self. loginButton setTitle: @ "login" forState: UIControlStateNormal]; [self. view addSubview: self. loginButton]; // The register button to set self. registrationButton = [[UIButton alloc] initWithFrame: CGRectMake (WIDTH * 0.1, HEIGHT * 0.45, WIDTH * 0.8, HEIGHT * 0.08)]; [self. registrationButton setBackgroundImage: [UIImage imageNamed: @ "rigisterButton"] forState: UIControlStateNormal]; [self. registrationButton setTitle: @ "register" forState: UIControlStateNormal]; [self. registrationButton setTitleColor: [UIColor colorWithRed: 0.115 green: 0.749 blue: 0.769 alpha: 1.000] forState: UIControlStateNormal]; [self. view addSubview: self. registrationButton] ;}# pragma Mark-logo image settings-(void) setLoginImage {// welcome image settings UIImageView * welcomeView = [[UIImageView alloc] initWithImage: [UIImage imageNamed: @ "welcome"]; welcomeView. frame = CGRectMake (WIDTH * 0.1, HEIGHT * 0.05, WIDTH * 0.8, HEIGHT * 0.08); [self. view addSubview: welcomeView]; // set UIImageView * LogoView for the logo image = [[UIImageView alloc] initWithImage: [UIImage imageNamed: @ "logo"]; LogoView. frame = CGRectMake (WIDTH * 0.4, HEIGHT-HEIGHT * 0.08, WIDTH * 0.2, HEIGHT * 0.03); [self. view addSubview: LogoView] ;}# pragma Mark-hide the keyboard/*** click the blank space to hide the keyboard ** @ param touches blank space * @ param event click */-(void) touchesBegan :( NSSet <UITouch *> *) touches withEvent :( UIEvent *) event {if ([self. nameTextfild isFirstResponder] | [self. passwordTextfild isFirstResponder]) {[self. nameTextfild resignFirstResponder]; [self. passwordTextfild resignFirstResponder];}/*** click return to hide the keyboard */-(BOOL) textFieldShouldReturn :( UITextField *) textField {[self. passwordTextfild resignFirstResponder]; return YES ;}... @ end
Run:
22:22:01