课程来自慕课网Visitor.zc老师
UILabel
UILabel *label = [[UILabel alloc] init];
label.frame = CGRectMake(10, 100, 300, 300);
label.backgroundColor = [UIColor yellowColor];
label.text = @"It's a label.It's a label.It's a label.It's a label.It's a label.It's a label.It's a label.It's a label.It's a label.It's a label.It's a label.It's a label.It's a label.It's a label.It's a label.It's a label.It's a label.It's a label.It's a label.It's a label.It's a label.It's a label.It's a label.It's a label.It's a label.It's a label.It's a label.It's a label.";
label.textAlignment = NSTextAlignmentCenter; // 文字排版
label.textColor = [UIColor colorWithRed:0.3 green:0.4 blue:0.9 alpha:1];
label.alpha = 0.5;
// label.font = [UIFont systemFontOfSize:25];
// label.font = [UIFont boldSystemFontOfSize:25];
label.font = [UIFont fontWithName:@"Bodoni 72" size:15];
// label.shadowColor = [UIColor darkGrayColor]; // 阴影颜色
// label.shadowOffset = CGSizeMake(10, 10); // 阴影偏移
// label.lineBreakMode = NSLineBreakByCharWrapping; // 换行模式
label.lineBreakMode = NSLineBreakByWordWrapping;
// label.numberOfLines = 10;
label.numberOfLines = 0;
[self.view addSubview:label];
UIImageView
NSString *path = [[NSBundle mainBundle] resourcePath];
NSString *imagePath = [NSString stringWithFormat:@"%@/1.png",path];
UIImage *image = [[UIImage alloc] initWithContentsOfFile:imagePath]; // 会自动释放内存
UIImage *image1 = [UIImage imageNamed:@"1"]; // 存在缓存中,运行结束后释放
UIImageView *imageView = [[UIImageView alloc] initWithImage:image];
imageView.frame = CGRectMake(10, 100, 355, 400);
imageView.backgroundColor = [UIColor yellowColor];
[self.view addSubview:imageView];
imageView.contentMode = UIViewContentModeCenter; // 内容居中
// imageView动画 - 播放序列图
NSMutableArray *imageArray = [[NSMutableArray alloc] init];
for (int i=1; i<=13; i++) {
UIImage *image = [UIImage imageNamed: [NSString stringWithFormat:@"png%d",i]];
[imageArray addObject:image];
}
UIImageView *imageView1 = [[UIImageView alloc] init];
imageView1.frame = CGRectMake(0, 100, 407, 217);
[self.view addSubview:imageView1];
imageView.animationImages = imageArray; // 设置图片数组
imageView.animationDuration = 2; // 设置播放周期时间
imageView.animationRepeatCount = 10; // 执行次数
[imageView startAnimating]; // 开始播放动画
图像的转化和保存
UIImage *image = [UIImage imageNamed:@"j1.jpg"];
NSData *data = UIImagePNGRepresentation(image);
UIImage *pngimage = [UIImage imageWithData:data];
UIImageWriteToSavedPhotosAlbum(pngimage, nil, nil, nil); // 保存至系统相册 需要申请权限