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

发布于 2022-09-06 07:24:13 字数 1446 浏览 61 评论 0

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);
    }]; }


如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

夏末染殇 2022-09-13 07:24:13

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

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

图片描述

戏舞 2022-09-13 07:24:13

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文