_window = [[UIWindow alloc]initWithFrame:[UIScreen mainScreen].bounds];
_window.rootViewController = [[UIViewController alloc]init];
_window.rootViewController.view.userInteractionEnabled = NO;
//====================系统按钮============================
UIButton *button1 = [[UIButton alloc]initWithFrame:CGRectMake(100, 100, 100, 100)];
[_window addSubview:button1];
//设置文字及状态
[button1 setTitle:@"sdd" forState:UIControlStateNormal];
//设置文字颜色及状态
[button1 setTitleColor:[UIColor magentaColor] forState:UIControlStateNormal];
//设置图片及状态
[button1 setImage:[UIImage imageNamed:@"dasd"] forState:UIControlStateNormal];
//====================View的移动============================
UIView *view = [[UIView alloc]initWithFrame:CGRectMake(100, 500, 100, 100)];
[_window addSubview:button1];
view.frame = CGRectMake(1, 1, 1, 1);
view.center = CGPointMake(1, 1);
view.bounds = CGRectMake(0, 0, 1, 1);
//旋转
[view setTransform:CGAffineTransformMakeRotation(M_PI_2)];
//缩放
[view setTransform:CGAffineTransformMakeScale(1, 1)];
//平移
[view setTransform:CGAffineTransformMakeScale(-14, -12)];
//NSTimer scheduledTimerWithTimeInterval:<#(NSTimeInterval)#> target:<#(id)#> selector:<#(SEL)#> userInfo:<#(id)#> repeats:<#(BOOL)#>
//动画
//UIView animateWithDuration:0.3 animations:^{
//}
//====================UIImageView============================
UIImageView *imageView = [[UIImageView alloc]initWithFrame:CGRectMake(100, 500, 100, 100)];
//
imageView.image = [UIImage imageNamed:@"baoza1_1"];
[_window addSubview:imageView];
//================显示帧动画=================
//创建图片数组
NSMutableArray *arrays = [[NSMutableArray alloc]init];
for (int i = 1; i <4; i++) {
UIImage *image = [UIImage imageNamed:[NSString stringWithFormat:@"dasd%d",i]];
[arrays addObject:image];
}
//设置动画图片数组(数组元素必须是UIImage对象)
[imageView setAnimationImages:arrays];
//设置播放完一组动画所需要的时间(单位:秒)
[imageView setAnimationDuration:1];
//循环次数
[imageView setAnimationRepeatCount:5];
//开始动画
[imageView startAnimating];
//停止动画
[imageView stopAnimating];
_window.backgroundColor = [UIColor whiteColor];
[_window makeKeyAndVisible];
//================定时器=================
//1.定时器的创建
//参数1:时间间隔(定时的时间) 单位:秒
//参数2:响应消息的对象(调用方法的对象)
//参数3:消息(方法),可以带参数,但是只能带一个参数,而且参数的实参就是当前这个定时器对象本身
//参数4:需要传入到定时器中的对象,一般是nil
//参数5:是否重复
//功能:repeats是NO -> 间隔1秒的时间后,[self time]; repeats是YES -> 每隔1秒self去调用time一次
//定时器一创建就开启了
NSTimer *timer = [NSTimer scheduledTimerWithTimeInterval:0.5 target:self selector:@selector(method) userInfo:nil repeats:NO];
//暂停定时器
[timer setFireDate:[NSDate distantFuture]];
//开启定时器
[timer setFireDate:[NSDate distantPast]];
//================UITextField=================
UITextField * textField = [[UITextField alloc] initWithFrame:CGRectMake(100, 100, 200, 60)];
//2.添加到界面上
[self.window addSubview:textField];
//3.设置背景颜色
textField.backgroundColor = [UIColor whiteColor];
//============和文字相关的属性==============
//文字
textField.text = @"俄 sad sad";
//文字颜色
textField.textColor = [UIColor brownColor];
//字体
textField.font = [UIFont systemFontOfSize:10];
//对齐模式
textField.textAlignment = NSTextAlignmentCenter;
//占位文字,(它的颜色是浅灰色,不能被改变)
////显示的条件是当前的text为空
textField.placeholder = @"请输入名字";
//6.是否在开始编辑的时候清空文字(默认是 NO)
textField.clearsOnBeginEditing = YES;
//=============和显示相关的属性===============
//设置边框风格 Border Style
[textField setBorderStyle:UITextBorderStyleRoundedRect];
//设置清除按钮模式
[textField setClearButtonMode:UITextFieldViewModeAlways];
//设置左视图
UILabel *leftLable = [[UILabel alloc]initWithFrame:CGRectMake(100, 100, 40, 40)];
leftLable.text = @"账号";
textField.leftView = leftLable;
[textField setLeftViewMode:UITextFieldViewModeAlways];
//是否处于编辑状态
BOOL ret = textField.isEditing;
网友评论