1.view部分
sizeView为自己创建的view
视图是否隐藏 YES 隐藏 NO显示(默认)
sizeView.hidden=YES;
alpha 透明度 0 (透明) 1(不透)
sizeView.alpha=1;
获取子视图
NSLog(@"%@",_window);
调整子视图的前后位置
_window bringSubviewToFront:<#(UIView *)#>
将视图置于后端
_window sendSubviewToBack:<#(UIView *)#>
按索引交换两个视图的层级关系
exchangeSubviewAtIndex:<#(NSInteger)#> withSubviewAtIndex:<#(NSInteger)#>
删除
[sizeView removeFromSuperview];
2.label部分
设置文字
label.text = @"你好";
设置字体颜色
label.textColor = [UIColor greenColor];
文本对齐方式
label.textAlignment = NSTextAlignmentCenter;
改变字体的大小
label.font = [UIFont systemFontOfSize:30];
拓展
阴影并且给阴影颜色
label.shadowColor = [UIColor whiteColor];
lable字体自适应,系统默认为no
label.adjustsFontSizeToFitWidth = YES;
label.highlighted = YES;
设置边框的宽度及边框的颜色 注意:使用cg color
label.layer.borderWidth = 1;
label.layer.backgroundColor = [UIColor redColor].CGColor;
label.layer.backgroundColor = [UIColor redColor].CGColor;
将lable变成圆形 设置边框圆角
label.layer.cornerRadius = 10;
将lable设置成圆角
label.layer.masksToBounds = YES;
label.clipsToBounds设置子视图超越边界是否显示全
取消第一响应(常用于点击return键时收回键盘)
[textField resignFirstResponder];
输入框没有文字的时候显示提醒用户的内容
field.placeholder = @"请输入密码:";
field.textAlignment = NSTextAlignmentCenter;
输入框直接输入文字,当输入框存在文字的时候,textfield不显示placeholder
field.text = @"fdfsafas";
设置边框样式
field.borderStyle = UITextFieldViewModeWhileEditing;
右侧清除按钮出现的时间
field.clearButtonMode = UITextFieldViewModeWhileEditing;
field.secureTextEntry = YES;
键盘样式
field.keyboardType = UIKeyboardAppearanceAlert;
隐藏输入信息,多数使用在密码
field.secureTextEntry = YES;
开始编辑的时候清空里面的文字
field.clearsOnBeginEditing = YES;
按键 UIButton 多数用便利构造器进行初始化,不需要管理引用计数
3.button部分
UIButton *button = [UIButton buttonWithType:UIButtonTypeSystem];
button.frame = CGRectMake(0, 100, 100, 100);
button.backgroundColor = [UIColor greenColor];
button.frame = CGRectMake(0, 100, 100, 100);
button.backgroundColor = [UIColor greenColor];
button.tag = 1;
图片设置圆角
imageview1.layer.masksToBounds = YES;
imageview1.layer.cornerRadius = 40;
(xcode7以下版本适用)
1.键盘点击return调回的系统方法?????
1.先签协议 <UITextFieldDelegate>(系统自带)
2. textfield1.delegate = self;设置代理
3.写方法系统自带
-(BOOL)textFieldShouldReturn:(UITextField *)textField{
[self.view endEditing:YES];
return YES;
return YES;
}
(点击输入框外的界面收回键盘)只需添加此方法(所有的textfield都将取消第一响应)
-(void)touchesEnded:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
[self.view endEditing:YES];
[self.view endEditing:YES];
}
弹出提示框
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"账号:123密码:123" message:nil delegate:nil cancelButtonTitle:@"取消" otherButtonTitles:@"确定", nil];
[alert show];
[alert show];
[alert release];