/*
1、把label对象给实例化,任何对象都要实例化
2、给label设置frame
3、把创建的视图放在父视图上面
*控件之间的基本关系
*UILabel
*UIImageView
*/
#import "AppDelegate.h"
@interface AppDelegate ()
@end
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
//UIView显示一块有颜色的视图
[self.windowmakeKeyAndVisible];
/*
UIView *view = [[UIView alloc]init];
view.frame = CGRectMake(100, 100, 300, 300);
view.backgroundColor;
view.alpha;
[self.window addSubview:view];
// UILabel 标签控件:适合放一些短的文本。
// UILabel继承与UIView
UILabel *label = [[UILabel alloc]init];//把label对象给实例化,任何对象都要实例化
label.frame = CGRectMake(200, 200, 200, 80);//给label设置frame
label.text = @"ZKY第四期ios,1s2s2额手法而放弃飞额问题有问题有问题跳个舞问题问二哥我国";//给UILabel设置文本
label.textColor = [UIColor whiteColor];//textColor设置字体颜色
label.backgroundColor = [UIColor redColor];
label.textAlignment = NSTextAlignmentCenter;//给UILabel设置对其方式
//UIColor
//UIFont
// UIColor UIFont都是一种类,用他们来创建的对象一样需要实例化
UIFont *font = [UIFont systemFontOfSize:25];//系统默认字体,改变字体大小
// label.font = font;
label.font = [UIFont systemFontOfSize:13];//设置字体大小
label.font = [UIFont boldSystemFontOfSize:16];//在加粗的同时设置字体大小
label.font = [UIFont italicSystemFontOfSize:15];//在斜体的同时给字体设置大小
label.shadowColor = [UIColor blackColor];//设置阴影颜色
label.shadowOffset = CGSizeMake(5, 5);//设置阴影偏移量
// label.numberOfLines = 0;//给内容设置行数,0代表自适应行数,非0,代表是几行就几行
label.adjustsFontSizeToFitWidth = YES;//自适应字体,从而让内容尽量一行显示
[self.window addSubview:label];//把创建的视图放在父视图上面
*/
/*
*创建帧动画四要素:
1、设置间隔时间
2、准备图片素材
3、设置重复次数
4、开始动画
*/
UIImageView *imgeView = [[UIImageViewalloc]init];//UIImageView用来显示图片
// imgeView.image = [UIImage imageNamed:@"1.tiff"];//如果图片是PNG格式的,图片名不需要加后缀,否则都要加。
imgeView.frame = CGRectMake(10, 10, 50, 50);
[self.windowaddSubview:imgeView];
imgeView.animationDuration =0.01;//设置动画的时间间隔(默认时间秒)
// imgeView.animationImages = @[@"1.tiff"];//
// imgeView.animationRepeatCount;//
UIImage *img1 = [UIImageimageNamed:@"1.tiff"];
UIImage *img2 = [UIImageimageNamed:@"2.tiff"];
UIImage *img3 = [UIImageimageNamed:@"3.tiff"];
UIImage *img4 = [UIImageimageNamed:@"4.tiff"];
NSArray *array = @[img1,img2,img3,img4];
imgeView.animationImages = array;//给帧动画准备素材
imgeView.animationRepeatCount =0;//给动画设置次数 0表示无数次
[imgeView startAnimating];
return YES;
}
// #define k常量名 @""
// 宏定义就是用内容替换变量名
#define kContent @"我改过的内容"
#define kLabelX label.frame.origin.x
#define kScreenWidth [UIScreen mainScreen].bounds.size.height
@interface AppDelegate ()
@end
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// [self.window makeKeyAndVisible];
//
//
// /*
// * 控件之间的继承关系
// * UILabel
// * UIImageView
// */
//
// //UIView显示一块有颜色的试图
// UIView *view = [[UIView alloc]init];
// view.frame = CGRectMake(100, 100, 300, 300);
// [self.window addSubview:view];
//
// //UILable 标签控件,适合放一些
// //短的文本。
// //UILabel 继承于UIView
//
// //把label对象给实例化,任何对象都要实例化
// UILabel *label = [[UILabel alloc]init];
//
// //给label设置frame
// label.frame = CGRectMake(200, 200, 200, 150);
//
// //给UILabel设置文本。
// label.text = @"asasldjfsdklfjlsdfj";
//
//
// //textcolor设置字体颜色
// label.textColor = [UIColor whiteColor];
//
// //给UILabel设置对齐方式
// label.textAlignment = NSTextAlignmentCenter;
//
//
// //UIFont UIColor都是一种类,用他们来创建的对象一样需要实例化。
// //系统默认字体,并给设置字体大小
// UIFont *font = [UIFont systemFontOfSize:25];
//
//// label.font = font;
//
// //在加粗的同时设置字体大小
//// label.font = [UIFont boldSystemFontOfSize:25];
//
// //在设置斜体的同时给设置字体大小
// label.font = [UIFont italicSystemFontOfSize:25];
// //shadowColor设置阴影并给设置阴影颜色
// label.shadowColor = [UIColor blackColor];
//
// //设置阴影偏移量
// label.shadowOffset = CGSizeMake(10, 10);
//
// //给内容设置行数,0代表自适应行数,非0,是几就是几行
// label.numberOfLines = 0;
//
// //自适应字体,从而让内容尽量一行显示
// label.adjustsFontSizeToFitWidth = YES;
// label.backgroundColor = [UIColor redColor];
//
// //要把咱创建的试图放在他的父试图上面
// [self.window addSubview:label];
//
// //UIImageView用来显示图片
// UIImageView *imgView = [[UIImageView alloc]init];
//
// //如果图片是PNG格式的,图片名不需要加后缀,否则都要加
//// imgView.image = [UIImage imageNamed:@"程亚新.JPG"];
//
// imgView.frame = CGRectMake(10, 10, 300, 400);
//
// [self.window addSubview:imgView];
// /*
// * 创建帧动画四要素
// 1、设置间隔时间
// 2、准备图片素材
// 3、设置重复次数
// 4、开始动画
// */
//
//
// //animationDuration设置动画的时间间隔
// imgView.animationDuration = 1;
//
//
// UIImage *img1 = [UIImage imageNamed:@"程亚新.jpg"];
//
// UIImage *img2 = [UIImage imageNamed:@"张天.JPG"];
//
// NSArray *array = @[img1,img2];
//
// //给帧动画准备素材
// imgView.animationImages = array;
//
// //给动画设置重复次数
// imgView.animationRepeatCount = 0;
//
// [imgView startAnimating];
// imgView.contentMode
// CGRectGetHeight(<#CGRect rect#>)
// [UIScreen mainScreen].bounds.origin
//宏定义
//
// [self.window makeKeyAndVisible];
//
//
// UIImageView *imgView = [[UIImageView alloc]init];
//
// imgView.frame = CGRectMake(10, 10, 300, 300);
// imgView.image = [UIImage imageNamed:@"张天.jpg"];
// imgView.contentMode = UIViewContentModeCenter;
// imgView.clipsToBounds = YES;
//
// imgView.backgroundColor = [UIColor blackColor];
//
// [self.window addSubview:imgView];
//
// NSLog(@"%f",CGRectGetHeight(imgView.frame));
//
#pragma mark 补充
/*
* 延迟方法
* CGRectGetHeight(<#CGRect rect#>)
* [UIScreen mainScreen].bounds.origin
* 宏定义
* 宏定义的使用技巧
* 补充
*/
//延迟多少秒后执行相应的方法,用selector选择的方法一定要实现,否则会崩溃。
[self.windowmakeKeyAndVisible];
[selfperformSelector:@selector(start)withObject:nilafterDelay:5];
UILabel *label = [[UILabelalloc]init];
label.frame = CGRectMake(10, 20, 120, 49);
label.backgroundColor = [UIColorredColor];
label.text = kContent;
label.shadowColor = [UIColorwhiteColor];
label.shadowOffset = CGSizeMake(-1, -1);
[self.windowaddSubview:label];
// //第一种方式
// NSLog(@"label的x=%f",kLabelX);
// //第二种方式
// NSLog(@"label的height=%f",CGRectGetWidth(label.frame));
//UIScreen指的就是屏幕,能帮组我们获取到各种屏幕的宽和高
NSLog(@"屏幕的高=%f",kScreenWidth);
UIImageView *imgeView = [[UIImageViewalloc]init];
imgeView.frame = CGRectMake(30, 30, 300, 400);
imgeView.backgroundColor = [UIColorgrayColor];
imgeView.image = [UIImageimageNamed:@"张天.JPG"];
//在某个方向上让图片自适应,已达到最好看的效果。
imgeView.contentMode =UIViewContentModeScaleAspectFit;
//让图片充满整个frame
imgeView.contentMode =UIViewContentModeScaleToFill;
//取到图片的相应位置,并放到屏幕上,会超出设置的图片试图Frame
imgeView.contentMode =UIViewContentModeRight;
//裁剪掉超出试图frame的部分
imgeView.clipsToBounds = YES;
[self.windowaddSubview:imgeView];
return YES;
}
- (void)start{
}