自定义控件,实现部分

 - (id)initWithFrame:(CGRect)frame descriptionText:(NSArray *)inText/*需要输入两个字符串*/
{
self = [super init];//通过父类调用init初始化方法,产生一个对象,此处的self就是类的对象
//判断是否初始化成功,未初始化之前,self = nil
if (self)
{
UILabel *myLable = [[UILabel alloc] initWithFrame:CGRectMake(frame.origin.x, frame.origin.y, frame.size.width/, frame.size.height)];
myLable.text = inText[];
myLable.textColor = [UIColor blueColor];//字体颜色
[self addSubview:myLable];
UITextField *myText = [[UITextField alloc] initWithFrame:CGRectMake(frame.size.width/, frame.origin.y, frame.size.width/*, frame.size.height)];
myText.placeholder = inText[];
myText.borderStyle = UITextBorderStyleRoundedRect;//边框样式(圆角)
[self addSubview:myText];
}
return self;//self包括(super init、addSubview:myLablea、ddSubview:myText)
}

调用部分

 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
//设置window(注意:该处必须设置)
self.window = [[UIWindow alloc] init];
self.window.frame = [[UIScreen mainScreen] bounds];//指定window大小跟屏幕大下一致
self.window.backgroundColor = [UIColor grayColor];//UIWindow中的方法,背景颜色 MyUIView *myUIViewInstance1 = [[MyUIView alloc] initWithFrame:CGRectMake(, , , ) descriptionText:@[@"用户名:",@"请输入手机号或邮箱"]];
MyUIView *myUIViewInstance2 = [[MyUIView alloc] initWithFrame:CGRectMake(, , , ) descriptionText:@[@"密码:",@"必须同时包含字符和数字"]];
[self.window addSubview:myUIViewInstance1];
[self.window addSubview:myUIViewInstance2]; [self.window makeKeyAndVisible];//显示(使其可见)
return YES;
}

基础部分

 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
//程序入口
//设置window
self.window = [[UIWindow alloc] init];
// self.window.frame = CGRectMake(0, 0, 100, 100);//指定窗口位置和大小
self.window.frame = [[UIScreen mainScreen] bounds];//指定window大小跟屏幕大下一致
self.window.backgroundColor = [UIColor grayColor];//UIWindow中的方法,背景颜色
//设置view
//创建view1
UIView *view1 = [[UIView alloc] init];
// UIView *view1 = [[UIView alloc] initWithCoder:(NSCoder *)];
// UIView *view1 = [[UIView alloc] initWithFrame:(CGRect)];
view1.frame = CGRectMake(, , , );//设置位置大小
view1.backgroundColor = [UIColor orangeColor];//背景颜色
//将view1加入window
// [self.window addSubview:view1]; NSLog(@"---%@",self.window.subviews);
//集合会自动对它的元素做retain操作
/*
hidden:隐藏
alpha:透明度
supwiew:父视图
tag:标记,便于索引(比如view的索引)
eg:
view1.tag = 10;
UIView *v = [self.window viewWithTag:10];//索引view1
*/ //UIlable
UILabel *myLable = [[UILabel alloc] initWithFrame:CGRectMake(, , , )];
myLable.backgroundColor = [UIColor whiteColor];
[self.window addSubview:myLable]; //UItext
UITextField *myText = [[UITextField alloc] initWithFrame:CGRectMake(, , , )];
myText.borderStyle = UITextBorderStyleRoundedRect;//边框样式(圆角)
myText.placeholder = @"手机号/邮箱";//占位符
// [view1 addSubview:myText];
[self.window addSubview:myText]; //UIButton+点击事件
// UIButton *myButton = [[UIButton alloc] initWithFrame:CGRectMake(120, 150, 80, 30)];
UIButton *myButton = [UIButton buttonWithType:UIButtonTypeSystem];//标准系统按钮,圆角形
myButton.frame = CGRectMake(, , , );
myButton.backgroundColor = [UIColor orangeColor];//橙黄色
[myButton setTitle:@"登陆" forState:UIControlStateNormal];//设置标题和状态(正常)
[myButton addTarget:self/*对象*/ action:@selector(prin/*处理程序*/) forControlEvents:UIControlEventTouchUpInside/*事件*/];//松手检测
[self.window addSubview:myButton]; //UIAlertView
// UIAlertView *myAlert = [[UIAlertView alloc] initWithTitle:@"提示" message:@"请妥善保管你的密码" delegate:nil cancelButtonTitle:@"取消" otherButtonTitles:@"确定", nil];
// [myAlert show]; [self.window makeKeyAndVisible];//显示(使其可见)
return YES;
} - (void)prin
{
// NSLog(@"登陆成功");
UIAlertView *myAlert = [[UIAlertView alloc] initWithTitle:@"提示" message:@"请妥善保管你的密码" delegate:nil cancelButtonTitle:@"取消" otherButtonTitles:@"确定", nil];
[myAlert show];//显示
}

IOS 学习笔记之UI的更多相关文章

  1. IOS学习笔记25—HTTP操作之ASIHTTPRequest

    IOS学习笔记25—HTTP操作之ASIHTTPRequest 分类: iOS2012-08-12 10:04 7734人阅读 评论(3) 收藏 举报 iosios5网络wrapper框架新浪微博 A ...

  2. iOS学习笔记之ARC内存管理

    iOS学习笔记之ARC内存管理 写在前面 ARC(Automatic Reference Counting),自动引用计数,是iOS中采用的一种内存管理方式. 指针变量与对象所有权 指针变量暗含了对其 ...

  3. IOS学习笔记02---语言发展概述,计算机语言简介.

    IOS学习笔记02---语言发展概述,计算机语言简介. ------------------------------------------------------------------------ ...

  4. IOS学习笔记48--一些常见的IOS知识点+面试题

      IOS学习笔记48--一些常见的IOS知识点+面试题   1.堆和栈什么区别? 答:管理方式:对于栈来讲,是由编译器自动管理,无需我们手工控制:对于堆来说,释放工作由程序员控制,容易产生memor ...

  5. iOS学习笔记31-从图册获取图片和视频

    一.从图册中获取本地图片和视频 从图册中获取文件,我们使用的是UIImagePickerController,这个类我们在之前的摄像头中使用过,这里是链接:iOS学习笔记27-摄像头,这里我们使用的是 ...

  6. iOS学习笔记13-网络(二)NSURLSession

    在2013年WWDC上苹果揭开了NSURLSession的面纱,将它作为NSURLConnection的继任者.现在使用最广泛的第三方网络框架:AFNetworking.SDWebImage等等都使用 ...

  7. iOS学习笔记——AutoLayout的约束

    iOS学习笔记——AutoLayout约束 之前在开发iOS app时一直以为苹果的布局是绝对布局,在IB中拖拉控件运行或者直接使用代码去调整控件都会发上一些不尽人意的结果,后来发现iOS在引入了Au ...

  8. IOS学习笔记之关键词@dynamic

    IOS学习笔记之关键词@dynamic @dynamic这个关键词,通常是用不到的. 它与@synthesize的区别在于: 使用@synthesize编译器会确实的产生getter和setter方法 ...

  9. iOS学习笔记-精华整理

    iOS学习笔记总结整理 一.内存管理情况 1- autorelease,当用户的代码在持续运行时,自动释放池是不会被销毁的,这段时间内用户可以安全地使用自动释放的对象.当用户的代码运行告一段 落,开始 ...

随机推荐

  1. Android布局方式_RelativeLayout

    RelativeLayout(相对布局)允许子元素指定它们相对于其他元素或父元素的位置(通过ID指定),因此用户可以右对齐,或上下对齐,或置于屏幕中央的形式来排列两个元素. RelativeLayou ...

  2. jQuery能做些什么

    来源于: Learning jQuery, 4th Edition What jQuery does: 1. Access elements in a document; $('div.content ...

  3. 美发帮--android APP开发实战

    登陆界面,LinearLayout  ImageView  Button   用到了ImageView自动缩放,和自定义Button形状及State-Drawable,还用到了动画. 自定义控件之圆形 ...

  4. android file path

    问题 出现的异常为:java.lang.IllegalArgumentException: File /mnt/sdcard/crazyit.bin contains a pathseparator. ...

  5. 【BZOJ 4539】【HNOI 2016】树

    http://www.lydsy.com/JudgeOnline/problem.php?id=4539 今天测试唯一会做的一道题. 按题目要求,如果暴力的把模板树往大树上仍,最后得到的大树是$O(n ...

  6. 状态压缩 HDU 1565

    多组数据 给你一个n*n的矩阵 不能相邻的取数 上下左右 求最大的和 #include<stdio.h> #include<algorithm> #include<str ...

  7. 怎么解决mysql不允许远程连接的错误

    最近使用Navicat for MySQl访问远程mysql数据库,出现报错,显示"1130 - Host'xxx.xxx.xxx.xxx' is not allowed to connec ...

  8. jquery.ui.widget详解

    案例详解 <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <titl ...

  9. 进程间通信方式与Binder机制原理

    1, Intent隐式意图携带数据 2, AIDL(Binder) 3, 广播BroadCast 4, 内容提供者ContentProvider --------------------------- ...

  10. 如何在HTMl网页中插入百度地图

    方法/步骤 1.打开"百度地图生成器"的网址:http://api.map.baidu.com/lbsapi/creatmap/index.html 如下图: 2.在"1 ...