Masonry/SnapKit自动布局适配UIScrollVie

2021-05-06  本文已影响0人  Jesscia_Liu

1. 子控件用约束布局的时候使用right会失效

        scrollView.addSubview(testView)
        testView.snp.makeConstraints {
            $0.top.equalTo(10)
            $0.left.equalTo(10)
            $0.width.equalTo(100)
            $0.height.equalTo(100)
        }

2.使用自动布局如何设置UIScrollView的contentSize

        scrollView.addSubview(testView)
        testView.snp.makeConstraints {
            $0.top.equalTo(10)
            $0.left.equalTo(10)
            $0.width.equalTo(100)
            $0.height.equalTo(100)
            $0.right.equalTo(0)
        }
        scrollView.addSubview(testView)
        testView.snp.makeConstraints {
            $0.top.equalTo(10)
            $0.left.equalTo(10)
            $0.width.equalTo(100)
            $0.height.equalTo(100)
            $0.bottom.equalTo(0)
        }
上一篇 下一篇

猜你喜欢

热点阅读