zoukankan      html  css  js  c++  java
  • iOS UICollectionView reloadData后立即获取contentSize.height高度

    自定义view重写layoutsubviews 方法

    核心属性 listView.collectionViewLayout.collectionViewContentSize.height
    tableview 同样适用

    - (void)layoutSubviews
    {
        [super layoutSubviews];
        ///列表高度
        CGFloat listHeight = 0;
        
        if (self.isMoreAlert) {//高度高一些
            self.listBgView.backgroundColor = UIColor.whiteColor;
            [self.listBgView mas_updateConstraints:^(MASConstraintMaker *make) {
                if (@available(iOS 11.0, *)) {
                    make.top.equalTo(self.mas_safeAreaLayoutGuideTop).offset(48.5);
                } else {
                    make.top.equalTo(self).offset(48.5);
                }
            }];
            
            if (self.listView.collectionViewLayout.collectionViewContentSize.height > 420) {
                self.listView.showsVerticalScrollIndicator = YES;
            }
            listHeight = MIN(self.listView.collectionViewLayout.collectionViewContentSize.height, 420) ;
        }else{
            self.listBgView.backgroundColor = colorFromRGB(0xF6F7FB);
            listHeight = MIN(self.listView.collectionViewLayout.collectionViewContentSize.height, 265) ;
            if (self.listView.collectionViewLayout.collectionViewContentSize.height > 265) {
                self.listView.showsVerticalScrollIndicator = YES;
            }
        }
        
        [self.listView mas_updateConstraints:^(MASConstraintMaker *make) {
            make.height.mas_equalTo(listHeight);
        }];
        
        [self.grayView mas_updateConstraints:^(MASConstraintMaker *make) {
            make.top.left.right.equalTo(self.listView);
            make.bottom.equalTo(self);
        }];
    }
  • 相关阅读:
    _#【命名】 / _
    _#【插件】
    _#【命名】样式类
    linux dd命令
    python urllib2和urllib的区别
    hadoop的find
    hadoop的fs基本命令
    /etc/profile和 . profile 文件
    广告sdk
    linux下查找文件的常用命令
  • 原文地址:https://www.cnblogs.com/qingzZ/p/14365408.html
Copyright © 2011-2022 走看看