Buttion控件
//添加一个按钮
UIButton *btn = [UIButton buttonWithType:UIButtonTypeSystem];
//设置大小
btn.bounds = CGRectMake(0, 0, 60, 40);
//设置中心点
btn.center = CGPointMake(screen / 2, 40);
//设置显示的文字
[btn setTitle:@"下一页" forState:UIControlStateNormal];
//设置btn的背景颜色
btn.backgroundColor = [UIColor blueColor];
//设置圆角
btn.layer.cornerRadius = 5;
//设置阴影
btn.layer.shadowColor = [UIColor grayColor].CGColor;
//设置偏移量
btn.layer.shadowOffset = CGSizeMake(5, 10);
//设置透明度
btn.layer.shadowOpacity = 1;
//添加事件
[btn addTarget:self action:@selector(btnClicked) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:btn];
//设置btn的位置和大小(整个屏幕那么大)
_btn.frame = CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height);
//设置btn的字体位置
_btn.titleLabel.textAlignment = NSTextAlignmentCenter;
//设置btn字体颜色
_btn.titleLabel.textColor = [UIColor redColor];
UITextField文本控件
//添加一个文本控件
UITextField *textField = [[UITextField alloc]init];
//设置文本控件的背景颜色
textField.textColor = [UIColor whiteColor];
//设置文本控件光标颜色
textField.tintColor = [UIColor whiteColor];
//设置文本控件文本位置
textField.textAlignment = NSTextAlignmentRight;
//设置文本控件文本内容
textField.text = @"0";
//设置文本控件位置大小
textField.frame = CGRectMake(2, 150, screen-10, 20);
//设置字体和粗细
textField.font = [UIFont systemFontOfSize:25 weight:0.5];
//设置文本颜色
textField.textColor = [UIColor blueColor];
_text = textField;
[self.view addSubview:textField];
UILabel文本标签控件
UILabel *titleLabel = [[UILabel alloc]init];
//获取屏幕的尺寸
CGFloat screen = [UIScreen mainScreen].bounds.size.width;
//设置尺寸
titleLabel.bounds = CGRectMake(0, 0, screen, 44);
//设置中心点
titleLabel.center = CGPointMake(screen/2, 42);
//设置背景色
titleLabel.backgroundColor = [UIColor grayColor];
//设置内容
titleLabel.text = @"标题栏";
//文本位置
titleLabel.textAlignment = NSTextAlignmentCenter;
//字体大小和粗细
titleLabel.font = [UIFont systemFontOfSize:24 weight:0.2];
新手总结。。学习得还是比较少。另外还有对于视图一个弹出弹入的两个动画方法。
//窗口弹入来
[self presentViewController:myView animated:YES completion:^{
NSLog(@"ss");//这里是动画结束后要做的事情
}];
//当前窗口弹出去
[self dismissViewControllerAnimated:YES completion:nil];//动画完成后事件也可以为空
暂时说到这里吧。。上课继续。。