iOS笔记2

  1. hud
    江湖人称为: 蒙版/遮盖/hud

    1. alpha 0.0完全透明 1.0 没有透明度

    2. 渐变动画

      帧动画 一帧一帧的播放动画(一张一张图片的切换)
      //帧动画
      // 设置动画图片
      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) {
      
              }];
          }];
      
  2. 按钮的内部结构
    图片 和 标题 间距
    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);
    }
    
  3. 图片的拉伸 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];

  4. copy

    1. 深拷贝 对象拷贝 产生一个新对象
    2. 浅拷贝 指针拷贝 指向同一个地址
    3. strong / copy
      strong 两个会跟着发生改变
      copy 拷贝一个副本,改变副本不会影响源文件, 改变源文件不会影响到副本
    4. property copy 在set方法中写 _str = [str copy];
    5. 调用copy的时候, 返回的是一个不可变对象
    6. 调用mutableCopy 返回一个可变对象

//自己创建的类如果要复制,必须要先遵守

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值