ios-study Record "01"

Source: Internet
Author: User
Tags set background home screen uikit

Have not written a blog for a long time, starting from today will record some learning experience/process. The interest in learning iOS is becoming more and more intense now. The development of small programs is over, and the product is currently being improved and functionally optimized.

The first iOS should be born today, two days beginning to touch some iOS grammar, OC object concept is not fully familiar with, feel very new.

viewcontroller.m//more////Created by Vjia on 2017/8/1.//Copyright? 2017 Vjia. All rights reserved.//#import "ViewController.h" #import "Uikit/uikit.h" @interface Viewcontroller () {Uitextfield *_txt username;//declares the control variable Uitextfield *_txtpassword;}    @end @implementation viewcontroller-(void) viewdidload {[Super viewdidload];    [Self loadloginform];//loads}-(void) didreceivememorywarning {[Super didreceivememorywarning] in the current object; Dispose of any resources the can be recreated.} -(void) loadloginform{//instantiation of the loaded control UILabel *lbusername=[[uilabel alloc] Initwithframe:cgrectmake (20, 160, 100, 40)];//        Draw text box size [email protected] "User name:";//Set text box text [Self.view addsubview:lbusername]; _txtusername=[[uitextfield Alloc] Initwithframe:cgrectmake (80, 160, 280, 40)];//Draw the text box size [_txtusername setborderstyle: uitextborderstyleroundedrect];//set Border style _txtusername.layer.bordercolor=[[uicolor Graycolor] cgcolor];//Set the color of the border _ txtusername.layer.borderwidth=0.7f;//Setting the border width _txtusername.layer.cornerradius=6.0f;//set rounded border size [email protected] "Please enter user name"; _txtusername.clearbuttonmode=uitextfieldviewmodealways;//the right side of the text box always displays the delete corner mark [Self.view addsubview:_txtusername];//    Add the control to the current view UILabel *lbpassword=[[uilabel Alloc] Initwithframe:cgrectmake (20, 220, 100,40)];    [email protected] "Password:";        [Self.view Addsubview:lbpassword];    _txtpassword=[[uitextfield Alloc] Initwithframe:cgrectmake (80, 220, 280, 40)];    [_txtpassword Setborderstyle:uitextborderstyleroundedrect];    _txtpassword.layer.bordercolor=[[uicolor Graycolor] Cgcolor];    _txtpassword.layer.borderwidth=0.7f;    _txtpassword.layer.cornerradius=6.0f;    [email protected] "Please enter the password";    _txtpassword.clearbuttonmode=uitextfieldviewmodealways;        [Self.view Addsubview:_txtpassword];    UILabel *lbforget=[[uilabel Alloc] Initwithframe:cgrectmake (20, 280, 100, 50)];    [email protected] "forgot password?";    [Lbforget Settextcolor:[uicolor Bluecolor];  [Self.view Addsubview:lbforget];      UILabel *lbreg=[[uilabel Alloc]initwithframe:cgrectmake (320, 280, 100, 50)];    [email protected] "registration";        [Lbreg settextcolor:[uicolor redcolor]];//Sets the color of the font [Self.view Addsubview:lbreg];        CGRect Rect=[[uiscreen Mainscreen] bounds];//Get home Screen object cgsize size=rect.size;//screen size cgfloat width=size.width;//width UIButton *btnlogin=[uibutton buttonwithtype:uibuttontypecustom];//If the button requires a custom background picture button must be set to custom mode otherwise you will see the blue icon btnlogin.fr    Ame=cgrectmake (0,400, Width, 80+10); [Btnlogin setbackgroundcolor:[uicolor redcolor]];//set background color to red [Btnlogin Settitlecolor:[uicolor WhiteColor] ForState    : UIControlStateNormal];    [Btnlogin settitle:@ "Login" forstate:uicontrolstatenormal];    [Btnlogin.self addtarget:self Action: @selector (login) forcontrolevents:uicontroleventtouchupinside]; [Btnlogin setimage:[uiimage imagenamed:@ "Sourcebundle.bundle/login"] forstate:uicontrolstatenormal];//    Referencing a picture in a resource file as a background image [Btnlogin setimageedgeinsets:uiedgeinsetsmake (0, 25, 20, 25)]; [Self.viewAddsubview:btnlogin]; Uinavigationbar *navigationbar=[[uinavigationbar alloc] Initwithframe:cgrectmake (0, 0, Width, 50+10)];//Draw navigation [ Self.view addsubview:navigationbar];//Add to Current View Uinavigationitem *navitem=[[uinavigationitem Alloc] InitWithTitle : @ "Login"];//create navigation content and set title Uibarbuttonitem *barbutton=[[uibarbuttonitem alloc] initwithtitle:@ "Back" Style:uibarbuttonitem Styledone target:self Action: @selector (login)];//Create a button text on the navigation bar to return the method that joins the triggering event navitem.leftbarbuttonitem=barbutton;// button appears on the left side of the navigation bar [Navigationbar pushnavigationitem:navitem animated:no];//Displays the navigation bar}-(void) login{//login method NSString *mess    age=[nsstring stringwithformat:@ "user name%@ password%@", _txtusername.text,_txtpassword.text];//declares a variable of type string and receives the input of the text box Uialertview *alert=[[uialertview alloc] initwithtitle:@ "Warm tip" Message:message delegate:nil cancelbuttontitle:@ "OK" otherbuttontitles:nil];//Initialize popup [alert show];//pop-up modal form prompt} @end

The relevant instructions have been written in the comments. It feels like this is a way to start learning that writing code can be relatively tedious and should be well understood later. Another way to do this is to drag the controls to implement them, which is relatively straightforward.

Small white one, only record the learning experience and analysis of the process of learning.

ios-study Record "01"

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.