IOS学习之简单的登陆布局(一)
来源:互联网 发布:上瘾网络剧未删减全集 编辑:程序博客网 时间:2024/05/22 14:50
哈哈哈哈哈,成为土豪了,必须买个mac开始装逼了,买了也不能闲着 ,顺便就学学ios吧,就学一个简单的登陆界面,反正什么app都有登陆界面。开动!
先看看效果图:
我可以说很丑吗?
上点代码吧:
//// 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
1 0
- IOS学习之简单的登陆布局(一)
- ios学习 登陆框的简单获取(一)
- ios学习之autolayout自动布局的简单理解 即UIKIt dymanic的使用
- Python爬虫学习(简单的模拟登陆(一))
- SSH学习之Struts1入门的简单登陆案例。
- IOS学习记录之登陆界面各功能的实现
- ios学习之spritekit的简单学习
- ios界面设计学习之布局
- iOS简单的登陆界面代码
- Android开发学习之卡片式布局的简单实现
- Android开发学习之卡片式布局的简单实现
- CSS学习笔记之边缘属性和简单的布局
- 简单学习CSS网页布局 一
- Android简单布局------QQ登陆
- iOS自适应布局之Masonry(一)
- iOS自适应布局之Masonry(一)
- 使用线性布局实现简单登陆界面的实例
- ios简单登陆界面
- Zend Framework2 - Cache 用法
- 《c和指针》读书笔记3
- [java基础学习]04——Java基础语法(三)
- 数据结构与算法学习——冒泡排序
- 在MyEclipse中把JSP默认编码改为UTF-8
- IOS学习之简单的登陆布局(一)
- DBUtils架构分析
- poj3270 Cow Sorting
- POJ 2718 暴力枚举
- LeetCode 195 Tenth Line
- C++模板元编程(递归-->分解)
- Eclipse - Mac Os Default JRE missing
- LaTeX学习笔记
- mac:在当前文件夹打开terminal终端