*控件之间的继承关系
*UILabel 标签控件,适合放一些短的文本
****UILabel继承于UIView****
*UIImageView 图片动画
UIFont、UIColor都是一种类,用他们创建的对象一样需要实例化
宏定义-用内容替换变量名
#define Contant @"改成"/需要代替的
#define k常量名 @"改成的内容"
self.window = [[UIWindow alloc]initWithFrame:[UIScreen mainScreen].bounds];
UIViewController *vc = [[UIViewController alloc]init];
self.window.rootViewController = vc;
//makeKeyAndVisible 让窗口是主窗口,并且显示在屏幕上
[self.window makeKeyAndVisible];
UIView *view = [[UIViewalloc]initWithFrame:CGRectMake(100, 100, 200, 200)];
// view.backgroundColor = [UIColor cyanColor];
[self.window addSubview:view];
secureTextEntry 密文形式显示输入内容
//把label对象给实例化
UILabel *label = [[UILabel alloc]init];
//给label对象设置尺寸
label.backgroundColor = [UIColor orangeColor];
label.frame = CGRectMake(100, 100, 200, 200);
//给UILabel设置文本
label.text = @"IOS蓝科四期 IOS蓝科四期";
//设置字体颜色
label.textColor = [UIColor redColor];
//设置字体对齐方式 (左、右、中)
label.textAlignment = NSTextAlignmentCenter;
//设置字体大小
label.font = [UIFont systemFontOfSize:30];
//设置字体加粗,同时设置字体大小
label.font = [UIFont boldSystemFontOfSize:25];
//在设置斜体的同时给设置字体大小(中文斜体无效果)
label.font = [UIFont italicSystemFontOfSize:25];
//设置阴影并给设置阴影颜色
label.shadowColor = [UIColor whiteColor];
//设置字体阴影偏移量
label.shadowOffset = CGSizeMake(1, 2);
//设置字体换几行(设置0 代表自适应)
label.numberOfLines = 1;
//是否设置内容尽量一行显示?调整字体大小以适应宽度
label.adjustsFontSizeToFitWidth = YES;
//把咱们创建的视图放到父视图上
[self.window addSubview:label];
#pragma ---创建帧动画四要素---
UIImageView *imgView = [[UIImageViewalloc]init];
[self.window addSubview:imgView];
//添加图片 如果是PNG格式的 图片名不需要加后缀,图片是什么格式就加什么后缀
// imgView.image = [UIImage imageNamed:@"图1.tiff"];
imgView.frame = CGRectMake(250, 250, 150, 150);
//1.设置动画的时间间隔 animationDuration
imgView.animationDuration = 1;
//2.准备并设置动画的素材 animationImages
UIImage *img1 = [UIImage imageNamed:@"图1.tiff"];
UIImage *img2 = [UIImage imageNamed:@"图2.tiff"];
NSArray *array = @[img1,img2];
imgView.animationImages = array;
//3.设置动画的重复次数
imgView.animationRepeatCount = 100;
//4.开始动画
[imgView startAnimating];
#pragma mark ---补充---
/*
* 延迟方法
* CGRectGetHeight(<#CGRect rect#>)
* [UIScreen mainScreen].bounds.origin
* 宏定义
* 宏定义的使用技巧
* 补充
*/
//延迟多少秒后执行相应的方法,用@selector选择的方法一定要实现,否则会崩溃。
[self performSelector:@selector(start) withObject:nil afterDelay:5];
//获取某框图宽和高
NSLog(@"label的height/Width=%f",CGRectGetWidth(label.frame));
//获取屏幕的宽和高 width height
NSLog(@"宽=%f",[UIScreen mainScreen].bounds.size.width);
// 将 label.text = @"IOS蓝科四期 IOS蓝科四期";
// 改为label.text = k常量名;
//在某个方向上让图片自适应,已达到最好看的效果。
imgeView.contentMode = UIViewContentModeScaleAspectFit;
视图模式适合规模方面的内容
//让图片充满整个frame
imgeView.contentMode = UIViewContentModeScaleToFill;
//取到图片的相应位置,并放到屏幕上,会超出设置的图片试图Frame
imgeView.contentMode = UIViewContentModeRight;
//裁剪掉超出试图frame的部分
imgeView.clipsToBounds = YES;