美文网首页
UIScrollView不用再写setContentSize了

UIScrollView不用再写setContentSize了

作者: ttdiOS | 来源:发表于2021-02-20 10:23 被阅读0次

不用再写了:《《《 [self.myScrollView setContentSize:CGSizeMake(kScreenWidth, CGRectGetMaxY(self.gongWeiLocationCollectionView.frame)+kIPhoneXBottomHeight)];》》》

直接这样:先:

    [self.view addSubview:self.myScrollView];

    [self.myScrollView mas_makeConstraints:^(MASConstraintMaker *make) {

        make.top.equalTo(self.topBarView.mas_bottom).with.offset(kAutoW(0));

        make.width.mas_equalTo (kScreenWidth);

        make.left.right.mas_equalTo(0);

        make.bottom.mas_equalTo(kAutoW(-kIPhoneXBottomHeight));

    }];

然后最后一个添加的ui的 bottom.这样:make.bottom.equalTo(_myScrollView.mas_bottom).with.offset(-20);就可以了

    [_downloadImageView mas_makeConstraints:^(MASConstraintMaker *make) {

        make.centerX.equalTo(self.view);

        //        make.left.equalTo(self.view).with.offset(15);

        //        make.right.equalTo(self.view).with.offset(-15);

         make.top.equalTo(titleLabel.mas_bottom).with.offset(12);

        make.width.mas_offset(downloadImage.size.width);

        make.height.mas_offset(downloadImage.size.height);

 make.bottom.equalTo(_myScrollView.mas_bottom).with.offset(-20);

    }];

相关文章

网友评论

      本文标题:UIScrollView不用再写setContentSize了

      本文链接:https://www.haomeiwen.com/subject/hqstfltx.html