===================================
创建控件
===================================
--------------------------------------------------------------------
通用
--------------------------------------------------------------------
全局定义字符串
------------static NSString *const string = @"this is string";
控件自身地位属性
------------label.bounds = CGRectMake(0,0,200,200); (表示自己的原点为0,0,自己的基点在自己中心,自己的长宽为200)
设置RGBA颜色
------------[UIColor colorWithRed:255.0f/255 green:255.0f/255 blue:255.0f/255 alpha:0.8f];
将控件进行居中
------------label.center = CGPointMake(self.view.center.x,self.view.center.y); (使用一个点进行定位)
页面返回到上一个页面
------------[self dismissViewControllerAnimated:YES completion:nil];
页面跳转到下一个页面
------------[self presentViewController:pageName animated:YES completion:nil];
整个视图具有结束编辑功能
------------[self.view endEditing:YES];
协议的继承
------------@interface VIewController ()<UITextFieldDelegate>
自己遵从协议
-----------self.delegate = self;
--------------------------------------------------------------------
视窗
--------------------------------------------------------------------
创建一个新视图窗口
------------self.window = [[UIWindow alloc]initWithFrame:[UIScreen mainScreen].bounds];
创建是一个视图控制器
------------ViewController = viewVi = [[ViewController alloc]init];
设置为跟控制器
------------self.window.rootViewController = viewVi;
将我们设置的视图窗口进行加载
------------[self.window makeKeyAndVisible];
创建任何一个控件的时候,一定要及时让它显示
------------[self.view addSubview:Kongjianname];
将视图层放到后面
------------[self.view sendSubviewToBack:shituceng];
将视图层放到前面
------------[self.view bringSubviewToFront:shituceng];
页面间跳转效果
------------ page.modalTransitionStyle = 枚举效果项;
页面之间传值
------------ newPage.index(新页面的属性) = oldPage.tag(就页面的指定值);
--------------------------------------------------------------------
文本框
--------------------------------------------------------------------
创建 -- 文本框
------------UILabel *label = [[UILabel alloc]init];
创建 -- 文本框2
------------UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(startX,startY,width,height)];
大小,位置
------------ label.frame = CGReckMake(startX,startY,width,height);
背景颜色
------------label.backgroundColor = [UIColor yellowColor];
禁用状态
------------label.enable = NO; (此时为禁用状态,无法修改样式)
高亮颜色
------------ label.highlightedTextColor = [UIColor whiteColor];
阴影颜色
------------[label setShadowColor:[UIColor whiteColor]];
阴影偏移
------------[label setShadowOffset:CGSizeMake(-1,-1)];
边框颜色
------------label.layer.borderColor = [[UIColor whiteColor] CGColor];
边框宽度
------------ label.layer. borderWidth = 2;
文本内容
------------label.text = @“Hello world”;
字体颜色
------------ label.textColor = [UIColor yellowColor];
文本高亮
------------label.highlighed = YES; (此时文本高亮)
内容居中
------------label.textAlignment = NSTextAlignmentCenter;
文字行数
------------label.numberOfLines = 2; (如果写0则表示多行)
字体填满
------------label.adjustsLetterSpacingToFItWidth = YES; (增大字间隙填满)
字体大小自适应
------------label.adjustsFontSizeToFitWidth = YES; (调整字体大小填满)
文字追加换行
------------label.numberOfLines = [label.text.length];
字体大小
------------label.font = [UIFont systemFontOfSize:20]; (标准)
boldSystemFontOfSize:20 (加粗)
fontWithName:@“Arial” size:16 (指定)
--------------------------------------------------------------------
输入框
--------------------------------------------------------------------
创建-输入框
------------UITextField *textField = [[UITextField alloc]initWithFrame:CGRectMake(startX,stratY,width,height)];
提示语句
------------textField.placeholder = @“请输入用户名”;
背景颜色
------------textField.backgroundColor = [UIColor yellowColor];
背景图片
------------textField.background = [UIImage imageNamed:@“img”];
输入框字体
------------textField.font = [UIFont fontWithName:@“Arial” size:16];
清空内容
------------textField.text = nil;
二次编辑清空
------------textField.clearsOnBeginEditing = YES;
溢出隐藏
------------textField.adjustsFontSizeToFitWidth = YES;
内容保密
------------textField.secureTextEntry = YES;
边角半径
------------textField.layer.cornerRadius = 8;
键盘样式
------------textField.keyboardType = UIKeyboardTypeDefault;
return键样式
------------textField.returnKeyType = UIReturnKeyTypedefault;
再次编辑时清空
------------textField.clearsOnBeginEditing = YES;
添加编辑事件
------------[textField addTarget:Self action:@selector(methodName) forControlEvents:UIControlEventEditingChange];
自己遵从协议
-----------textField.delegate = self;
是否第一响应者
------------[textField isFirstresponder]; (返回布尔类型)
取消第一响应 -- 回收键盘
------------[textField resignFirstResponder];
页面变为第一响应者
------------[twoPage becomeFirstResponder];
切换第一响应者
------------[self.suerPass becomeFirstResponder];
整个视图具有结束编辑功能
------------[self.view endEditing:YES];
边框样式
------------textField.borderStyle = UITextBorderStyleBezel; (尖锐)
UITextBorderStyleLine; (线条)
UITextBorderStyleRoundedRect (圆角)
--------------------------------------------------------------------
按钮
--------------------------------------------------------------------
创建-按钮
------------UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom]; (定制)
大小位置
------------ button.frame = CGRectMake(startX,startY,width,height);
背景颜色
------------button.backgroundColor = [UIColor whiteColor];
设置图片
------------[button setImage:[UIImage imageNamed:@“Image”] forState:UIControlStateNormal];
设置背景图片
------------[button setBackgroundImage:@“ImageName” forState:UIControlStateNormal];
默认文字
------------[button setTitle:@“登录” forState:UIControlStateNormal]; (正常状态)
默认文字颜色
------------[button setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
字体大小
------------button.titleLabel.font = [UIFont systemFontOfSize:20];
边角半径
------------button.layer.radius = 10;
按钮切角
------------button.layer.masksToBounds = YES;
按钮图片高亮
------------button.adjustsImageWhenHighlighted = YES;
点击光晕
------------button.showsTouchWhenHighLighted = YES;
激活状态文字
------------[button setTitle:@“正在登录” forState:UIControlStateSelected];
激活状态文字颜色
------------[button setTitleColor:[UIColor whiteColor] forState:UIControlStateSelected];
点击事件
------------[button addTarget:self action:@selector(自定义动作方法:) forControlEvents:UIControlEventTouchUpInside];
按钮状态切换
------------ button.select = !button.select;