你好,歡迎來到IOS教程網

 Ios教程網 >> IOS編程開發 >> IOS開發綜合 >> ios學習之簡單的登陸布局

ios學習之簡單的登陸布局

編輯:IOS開發綜合

哈哈哈哈哈,成為土豪了,必須買個mac開始裝逼了,買了也不能閒著 ,順便就學學ios吧,就學一個簡單的登陸界面,反正什麼app都有登陸界面。開動!

先看看效果圖:data-cke-saved-src=https://www.ios5.online/ios/UploadFiles_8070/201703/2017030909384358.png

 

 

 

上點代碼吧:

 

//
//  MineUiViewController.m
//  UITabview
//
//  Created by xiaoyuan on 15/4/16.
//  Copyright (c) 2015年 xiaoyuan. All rights reserved.
//

#import MineUiViewController.h


@interface MineUiViewController ()
{

    UITextField *phone;
    UITextField *code;
    UIButton *btn;
    UIButton *getcode;


}
@end

@implementation MineUiViewController



- (void)viewDidLoad {
    [super viewDidLoad];
    
    
    
    UILabel*title =[[UILabel alloc] initWithFrame:CGRectZero];
    title.backgroundColor =[UIColor clearColor];
    title.textColor =[UIColor whiteColor];
    self.navigationItem.titleView = title;
    title.text =@菜鳥;
    [title sizeToFit];
    

    
    
    

    self.navigationController.navigationBar.barTintColor = [UIColor redColor];
    [self.navigationController.navigationBar setTranslucent:NO];
    int width = (self.view.frame.size.width);
    int leftandright = 6;
    int top = 6;
    phone = [[UITextField alloc] initWithFrame:CGRectMake(top, top, width*2/3,50)];
    phone.textColor= [UIColor greenColor];
    phone.font = [UIFont systemFontOfSize:15];
    phone.placeholder =@請輸入手機號;
    phone.backgroundColor = [UIColor grayColor];
    phone.returnKeyType = UIReturnKeyDefault;
    phone.keyboardType =UIKeyboardTypeDefault;
    phone.delegate =self;
    phone.keyboardType =UIKeyboardTypeNumberPad;
    [self.view addSubview:phone];

    
    getcode = [[UIButton alloc] initWithFrame:CGRectMake(width*2/3+top*2,top, width*1/3-top*3, 50)];
    getcode.backgroundColor =[UIColor blackColor];
    [getcode setTitle:@fuck forState:UIControlStateNormal];
    [getcode addTarget:self action:@selector(getcode) forControlEvents:(UIControlEventTouchUpInside)];
    
    [self.view addSubview:getcode];
    
    
    
    int y = 50;
    y+=20;
    code = [[UITextField alloc] initWithFrame:CGRectMake(top, y, width-top*2, 50)];
    code.textColor= [UIColor blueColor];
    code.font = [UIFont systemFontOfSize:15];
    code.placeholder =@請輸入驗證碼;
    code.backgroundColor = [UIColor grayColor];
    code.returnKeyType = UIReturnKeyDefault;
    code.keyboardType =UIKeyboardTypeDefault;
    code.delegate =self;
    code.keyboardType =UIKeyboardTypeNumberPad;
    [self.view addSubview:code];
    y+=50;
    y+=20;
    btn =[[UIButton alloc]initWithFrame:CGRectMake(top, y, width-top*2, 50)];
    btn.backgroundColor = [UIColor redColor];
    [btn setTitle:@fuck forState:UIControlStateNormal];
    [btn addTarget:self action:@selector(getcode) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:btn];

 
}
-(void)getcode {
    UIAlertView *show  = [[UIAlertView alloc] initWithTitle:@你是逗比嗎 message:@你猜delegate:nil cancelButtonTitle:@是 otherButtonTitles:@是, nil];
    [show show];
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}



@en

 

對了 要想進入這個界面得appdelegate裡面改改:

 

//
//  AppDelegate.m
//  UITabview
//
//  Created by xiaoyuan on 15/4/16.
//  Copyright (c) 2015年 xiaoyuan. All rights reserved.
//

#import AppDelegate.h
#import MineUiViewController.h

@interface AppDelegate ()

@end

@implementation AppDelegate


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    // Override point for customization after application launch.
    
    
    //創建_window
    _window=[[UIWindow alloc] initWithFrame:CGRectMake(0, 0, 400, 600)];
    _window.backgroundColor=[UIColor whiteColor];
    MineUiViewController  *rootVC=[[MineUiViewController alloc] init];
    UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:rootVC];
    _window.rootViewController=nav;
    [_window makeKeyAndVisible];
   
    

    
  
    
    return YES;
}

- (void)applicationWillResignActive:(UIApplication *)application {
    // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
    // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}

- (void)applicationDidEnterBackground:(UIApplication *)application {
    // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
    // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}

- (void)applicationWillEnterForeground:(UIApplication *)application {
    // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}

- (void)applicationDidBecomeActive:(UIApplication *)application {
    // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}

- (void)applicationWillTerminate:(UIApplication *)application {
    // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}

@end

 

 

 

  1. 上一頁:
  2. 下一頁:
蘋果刷機越獄教程| IOS教程問題解答| IOS技巧綜合| IOS7技巧| IOS8教程
Copyright © Ios教程網 All Rights Reserved