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);
        }];
    }
  • 相关阅读:
    字符串-01. 在字符串中查找指定字符(15)
    数组-14. 数字加密(15)
    软考笔记第一天之数制
    基于c#开发的简易点名器
    软考笔记之存储管理
    IO inputStream和outputStream
    java可变参数
    Map集合总结
    Collection集合总结
    Struts 获得前台传参几种方式
  • 原文地址:https://www.cnblogs.com/qingzZ/p/14365408.html
Copyright © 2011-2022 走看看