hud
江湖人称为: 蒙版/遮盖/hudalpha 0.0完全透明 1.0 没有透明度
渐变动画
帧动画 一帧一帧的播放动画(一张一张图片的切换)
//帧动画
// 设置动画图片
self.imageView.animationImages = images;
// 设置播放次数
self.imageView.animationRepeatCount = 1;
// 设置图片
self.imageView.image = [UIImage imageNamed:@”stand_1”];
// 开始动画
[self.imageView startAnimating];1). 头尾式 开始动画 [UIView beginAnimations:nil context:nil]; // 动画时间 [UIView setAnimationDuration:2.0f]; self.hudLabel.alpha = 1.0; self.hudLabel.text = @"感觉满满的"; // 提交动画 [UIView commitAnimations]; 2). block 式 [UIView animateWithDuration:2.0f animations:^{ // 需要执行的代码 self.hudLabel.alpha = 1.0; self.hudLabel.text = @"感觉满满的"; // 延迟 4 s 调用 self 的 hideHud方法 [self performSelector:@selector(hideHud) withObject:nil afterDelay:4.0]; }]; 3) block 式 "带完成的block" [UIView animateWithDuration:2.0f animations:^{ // 需要执行的代码 self.hudLabel.alpha = 1.0; self.hudLabel.text = @"感觉满满的"; } completion:^(BOOL finished) { [UIView animateWithDuration:2.0f animations:^{ // 需要执行的代码 self.hudLabel.alpha = 0.0f; }]; }]; 4). block 式 "带完成的block 延迟的时间" [UIView animateWithDuration:1.0f animations:^{ // 需要执行的代码 self.hudLabel.alpha = 1.0f; } completion:^(BOOL finished) { // 延迟十秒 执行动画的代码 执行时间 是 2.0f [UIView animateWithDuration:1.0f delay:1.0f options:kNilOptions animations:^{ // 需要执行的代码 self.hudLabel.alpha = 0.0f; } completion:^(BOOL finished) { }]; }];
按钮的内部结构
图片 和 标题 间距
self.titleEdgeInsets; 改变标题在按钮中的位置
self.imageEdgeInsets 改变图片在按钮中的位置
self.contentEdgeInsets 改变按钮中所有内容的位置
设置内间距
图片 和 标题 位置布局
// 直接影响按钮内部的子控件
//缺陷 不知道先调用的是哪个方法
- (CGRect)titleRectForContentRect:(CGRect)contentRect
{
self.titleH = contentRect.size.height * 0.4;
return CGRectMake(0, 0, contentRect.size.width,self.titleH);
}- (CGRect)imageRectForContentRect:(CGRect)contentRect { return CGRectMake(0, contentRect.size.height * 0.4, contentRect.size.width, contentRect.size.height * 0.6); } 一般情况下 都是使用layoutSubviews 布局子控件 layoutSubviews 准确性极高 // 布局子控件 - (void)layoutSubviews { [super layoutSubviews]; self.titleLabel.frame = CGRectMake(0, 0, self.frame.size.width, self.frame.size.height * 0.4); self.imageView.frame = CGRectMake(0, self.titleLabel.frame.size.height, self.frame.size.width, self.frame.size.height * 0.6); }
图片的拉伸 http://blog.csdn.net/q199109106q/article/details/8615661
“默认是平铺的方式”
UIImage *resizeImg = [image resizableImageWithCapInsets:UIEdgeInsetsMake(10, 10, 10, 10)];“需要选择拉伸或者平铺的模式”
UIImage *resizeImg = [image resizableImageWithCapInsets:UIEdgeInsetsMake(10, 10, 10, 10) resizingMode:UIImageResizingModeTile];// 系统会根据你传入的左边的宽度 算出右边的宽度
// 1 = width - leftCapWidth - right
// 系统会根据你传入的顶部的高度算出底部的高度
// 1 = height - topCapWidth - bottom
// 拉伸的是1x1 的区域
UIImage resizeImg = [image stretchableImageWithLeftCapWidth:image.size.width 0.5 topCapHeight:image.size.height *0.5];copy
- 深拷贝 对象拷贝 产生一个新对象
- 浅拷贝 指针拷贝 指向同一个地址
- strong / copy
strong 两个会跟着发生改变
copy 拷贝一个副本,改变副本不会影响源文件, 改变源文件不会影响到副本 - property copy 在set方法中写 _str = [str copy];
- 调用copy的时候, 返回的是一个不可变对象
- 调用mutableCopy 返回一个可变对象
//自己创建的类如果要复制,必须要先遵守