IOS学习之简单的登陆布局(一)
2015-04-22 23:03
225 查看
哈哈哈哈哈,成为土豪了,必须买个mac开始装逼了,买了也不能闲着 ,顺便就学学ios吧,就学一个简单的登陆界面,反正什么app都有登陆界面。开动!
先看看效果图:
我可以说很丑吗?
上点代码吧:
对了 要想进入这个界面得appdelegate里面改改:
AppDelegate
AppDelegate
先看看效果图:
我可以说很丑吗?
上点代码吧:
// // MineUiViewController.m // UITabview // // Created by xiaoyuan on 15/4/16. // Copyright (c) 2015年 xiaoyuan. All rights reserved. // #import "MineUiViewController.h" @interface MineUiViewController ()<UITextFieldDelegate> { 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不知道为什么 苹果要加上navigationcontroller 这个不加或者加上这个但是这个是透明的算坐标的时候有点问题啊!新手大神勿喷!
AppDelegate
AppDelegate
相关文章推荐
- iOS学习(三十二)简单的登陆界面保存用户名到home,下次启动并显示出来
- ios学习之autolayout自动布局的简单理解 即UIKIt dymanic的使用
- iOS学习(三十三)使用NSUserDefaults简单的登陆界面保存用户名,下次启动并显示出来
- 从简单的android 登陆应用 ,学习布局,
- iOS学习之Table View的简单使用
- iOS学习之路-简单汤姆猫
- ios-AutoLayout(自动布局代码控制)简单总结
- 开源中国iOS客户端学习——(十二)用户登陆
- ios学习(十五)微博布局
- iOS(学习) 一个简单的动画效果
- ios学习笔记-属性列表(做一个简单的记事本)
- ios界面设计学习之布局
- 简单学习CSS网页布局 二
- Silverlight学习笔记一(理解一下机制,使用一下布局,实现一个简单的用户登录)
- AJ学IOS 之第一次打开Xcode_git配置,git简单学习
- iOS学习之VFL实现自动布局
- iOS学习笔记—— UItableView 控件的简单使用
- ios学习笔记——简单控件(开关、分段控件、滑块)
- 我的iOS学习历程 - UISlider(简单的设置一组图片动画)
- iOS学习笔记2—关于tableView的一些简单操作