3.大神班 scrollView 与 动画 imageView的加载图片

来源:互联网 发布:扫地机器人算法 编辑:程序博客网 时间:2024/05/22 14:18
  • self.scrollView.contentOffset : 偏移量
    • 记录UIScrollView滚动的位置,滚到哪
    • 总结:内容的左上角 和 scrollView自身左上角 的 X\Y差值
  • 设置内容大小
    • self.scrollView.contentSize = imageView.image.size;
    • 不设置内容的大小,不会出现scrollView的滚动条,不会滚动
  • @property(nonatomic) UIEdgeInsets contentInset;

    • 这个属性能够在UIScrollView的4周增加额外的滚动区域,一般用来避免scrollView的内容被其他控件挡住
  • 其他属性

    • @property(nonatomic) BOOL bounces;
      设置UIScrollView是否需要弹簧效果

    • @property(nonatomic,getter=isScrollEnabled) BOOL scrollEnabled;
      设置UIScrollView是否能滚动

    • @property(nonatomic) BOOL showsHorizontalScrollIndicator;
      是否显示水平滚动条

    • @property(nonatomic) BOOL showsVerticalScrollIndicator;
      是否显示垂直滚动条

- 动画(3种表现,2种任何时候通用,一种只有在scrollView才能使用)

1.```objc    [UIView beginAnimations:nil context: nil];    [UIView setAnimationDuration:2.0];//设置动画播放时间    [UIView setAnimationDelegate:self]; // 代理    [UIView setAnimationDidStopSelector:@selector(stop)];//动开始时调用stop方法    [UIView setAnimationWillStartSelector:@selector(start)];//动画结束时调用方法start    //需要动画的代码    [UIView commitAnimations]```

2.

 [UIView animateWithDuration:2.0 animations:^{        //需要播放的动画    }];

3.

[self.scrollView setContentOffset:offset animated:YES];设置偏移量动画  
  • OC细节语法

    • self.scrollView.contentOffset.y = offsetY
    • OC语法细节:不允许直接修改OC对象的结构体属性的成员
  • imageView的加载图片
    // UIImageView *imageView = [[UIImageView alloc] init];
    // imageView.image = [UIImage imageNamed:@”minion”];
    // imageView.frame = CGRectMake(0, 0, imageView.image.size.width, imageView.image.size.height);

    上面三句等价于下面一句 在初始化时加载图片就相当于图片的大小等于imageView的大小

    UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@”minion”]];

0 0
原创粉丝点击