iOS下拉刷新的背景色问题,漏一截

UICollectionView下拉刷新,上面一个背景色,下面一个背景色。
一般可以在root View上绘制不同区块的颜色,设置Customize 的背景色。
也可以 在rootView 上, CollectionView 下 ,加一层带颜色的View.
CollectionView 拉过(边界)了,就不太好啦。 见底图。
我觉得,可以加一层带颜色的View, 通过 KVO , 或者 在 代理方法 - scrollViewDidScroll 中,动态调整带颜色的 View 的 Y值 ,和Height.
有点Low.
问下,有没有系统API 级别(UIScrollView)的解决方案。
求推荐更好的解决方案。

图片描述

附: UICollectionView 的初始化/ 布局代码

 - (UICollectionView *)mineCollectionView{
if(!_mineCollectionView){
UICollectionViewFlowLayout * defaultLayout = [[UICollectionViewFlowLayout alloc] init];
        defaultLayout.minimumLineSpacing = 0;
        defaultLayout.minimumInteritemSpacing = 0;
         _mineCollectionView = [[UICollectionView alloc] initWithFrame: CGRectZero collectionViewLayout: defaultLayout];
         ····
     }
     return _mineCollectionView;
 }
         
    
    

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
   
    [self.view addSubview: self.mineCollectionView];
    [self.mineCollectionView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.mas_topLayoutGuide);
        make.left.equalTo(self.view);
        make.right.equalTo(self.view);
        make.bottom.equalTo(self.mas_bottomLayoutGuide);
    }]; }


阅读 8.3k
2 个回答

在tableView的顶部添加一个蓝色背景的UIIView

UIView *bgView = [[UIView alloc] initWithFrame:CGRectOffset(_tableView.bounds, 0, -_tableView.bounds.size.height)];
bgView.backgroundColor = [UIColor blueColor];
[_tableView insertSubview:bgView atIndex:0];

图片描述

感觉要点还是在, UICollectionDecorationView,
难道要decorationView 动态布局

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题