ios – Backside parts in UIScrollView dont present/scroll when utilizing autolayout

0
46


I cannot get all of the content material to indicate inside my scrollview utilizing autolayout by way of snapkit library. Tried with totally different constrants however my buttons on backside are by no means proven in full and nothing could be scrolled.
My code:

personal func setupViews() {

    let window = UIApplication.shared.home windows[0]
    let safeFrame = window.safeAreaLayoutGuide.layoutFrame
    let bottomSafeOffset = window.body.maxY - safeFrame.maxY

    title = NSLocalizedString("bank_connection_disconnect_title", remark: "")

    view.addSubview(scrollView)
    scrollView.snp.makeConstraints { (make) in
        make.prime.equalTo(self.view.safeAreaLayoutGuide.snp.prime)
        make.main.trailing.equalTo(0)
        make.backside.equalTo(self.view.backside)
    }

    let contentView = UIView(body: CGRect.zero)
    scrollView.addSubview(contentView)
    contentView.snp.makeConstraints { (make) in
        make.width.top.prime.backside.equalTo(scrollView)
    }

    //first container
    let accountsView = UIView(body: CGRect.zero)
    accountsView.backgroundColor = .white
    contentView.addSubview(accountsView)
    accountsView.snp.makeConstraints { (make) in
        make.main.trailing.equalTo(0)
        make.prime.equalTo(self.view.safeAreaLayoutGuide.snp.prime)
    }

    let topDelimiter = UIView(body: CGRect.zero)
    topDelimiter.backgroundColor = .delimiterColor
    accountsView.addSubview(topDelimiter)
    topDelimiter.snp.makeConstraints { (make) in
        make.prime.equalTo(0)
        make.left.proper.equalTo(0)
        make.top.equalTo(0.5)
    }

    let bottomDelimiter = UIView(body: CGRect.zero)
    bottomDelimiter.backgroundColor = .delimiterColor
    accountsView.addSubview(bottomDelimiter)
    bottomDelimiter.snp.makeConstraints { (make) in
        make.backside.equalTo(0)
        make.left.proper.equalTo(0)
        make.top.equalTo(0.5)
    }

    if let conn = viewModel.connection {
        let disconnectTitleLabel = UILabel(body: CGRect.zero)
        disconnectTitleLabel.font = ToshlFont.regularFont(ofSize: 14)
        disconnectTitleLabel.textColor = .textColor1
        disconnectTitleLabel.numberOfLines = 0
        disconnectTitleLabel.attributedText = String(format: NSLocalizedString("bank_connection_disconnect_subtitle", remark: ""), conn.title).htmlAttributedString()
        accountsView.addSubview(disconnectTitleLabel)
        disconnectTitleLabel.snp.makeConstraints { (make) in
            make.main.equalTo(20)
            make.trailing.equalTo(-20)
            make.top.equalTo(44)
            make.prime.equalTo(20)
        }

        let accountsTitleLabel = UILabel(body: CGRect.zero)
        accountsTitleLabel.font = ToshlFont.regularFont(ofSize: 14)
        accountsTitleLabel.textColor = .textColor1
        accountsTitleLabel.numberOfLines = 0
        accountsTitleLabel.textual content = NSLocalizedString("bank_connection_imported", remark: "")
        accountsView.addSubview(accountsTitleLabel)
        accountsTitleLabel.snp.makeConstraints { (make) in
            make.main.equalTo(20)
            make.trailing.equalTo(-20)
            make.prime.equalTo(disconnectTitleLabel.snp.backside).offset(25)
        }

        let accountsLabel = UILabel(body: CGRect.zero)
        accountsLabel.font = ToshlFont.regularFont(ofSize: 14)
        accountsLabel.textColor = .textColor1
        accountsLabel.numberOfLines = 0
        accountsLabel.textual content = viewModel.accountNamesSeparated()
        accountsView.addSubview(accountsLabel)
        accountsLabel.snp.makeConstraints { (make) in
            make.main.equalTo(20)
            make.trailing.equalTo(-20)
            make.prime.equalTo(accountsTitleLabel.snp.backside).offset(25)
            make.backside.equalTo(accountsView.backside).offset(-20)
        }
    }

    //second container
    let dataOptionsView = UIView(body: CGRect.zero)
    dataOptionsView.backgroundColor = .white
    contentView.addSubview(dataOptionsView)
    dataOptionsView.snp.makeConstraints { (make) in
        make.main.trailing.equalTo(0)
        make.prime.equalTo(accountsView.snp.backside).offset(25)
    }

    let topDelimiter2 = UIView(body: CGRect.zero)
    topDelimiter2.backgroundColor = .delimiterColor
    dataOptionsView.addSubview(topDelimiter2)
    topDelimiter2.snp.makeConstraints { (make) in
        make.prime.equalTo(0)
        make.left.proper.equalTo(0)
        make.top.equalTo(0.5)
    }

    let bottomDelimiter2 = UIView(body: CGRect.zero)
    bottomDelimiter2.backgroundColor = .delimiterColor
    dataOptionsView.addSubview(bottomDelimiter2)
    bottomDelimiter2.snp.makeConstraints { (make) in
        make.backside.equalTo(0)
        make.left.proper.equalTo(0)
        make.top.equalTo(0.5)
    }

    let dataOptionTitleLabel = UILabel(body: CGRect.zero)
    dataOptionTitleLabel.font = ToshlFont.regularFont(ofSize: 14)
    dataOptionTitleLabel.textColor = .textColor1
    dataOptionTitleLabel.numberOfLines = 0
    dataOptionTitleLabel.textual content = NSLocalizedString("bank_connection_disconnect_action", remark: "")
    dataOptionsView.addSubview(dataOptionTitleLabel)
    dataOptionTitleLabel.snp.makeConstraints { (make) in
        make.main.equalTo(20)
        make.trailing.equalTo(-20)
        make.prime.equalTo(25)
    }

    checkImageView = UIImageView(picture: checkImage)

    if let checkImageView = checkImageView {
        checkImageView.tintColor = .lightBurgundy
        dataOptionsView.addSubview(checkImageView)
        checkImageView.snp.makeConstraints { (make) in
            make.main.equalTo(20)
            make.width.equalTo(20)
            make.top.equalTo(20)
            make.prime.equalTo(dataOptionTitleLabel.snp.backside).offset(16)
        }
    }


    let keepDataLabel = UILabel(body: CGRect.zero)
    keepDataLabel.font = ToshlFont.regularFont(ofSize: 14)
    keepDataLabel.textColor = .textColor1
    keepDataLabel.numberOfLines = 0
    keepDataLabel.textual content = NSLocalizedString("bank_connection_disconnect_keep_data", remark: "")
    dataOptionsView.addSubview(keepDataLabel)
    keepDataLabel.snp.makeConstraints { (make) in
        make.left.equalTo(checkImageView!.snp.proper).offset(12)
        make.trailing.equalTo(-20)
        make.centerY.equalTo(checkImageView!)

    }

    let keepDataDescLabel = UILabel(body: CGRect.zero)
    keepDataDescLabel.font = ToshlFont.regularFont(ofSize: 14)
    keepDataDescLabel.textColor = .textColor1
    keepDataDescLabel.numberOfLines = 0
    keepDataDescLabel.textual content = NSLocalizedString("bank_connection_disconnect_keep_data_desc", remark: "")
    dataOptionsView.addSubview(keepDataDescLabel)
    keepDataDescLabel.snp.makeConstraints { (make) in
        make.left.equalTo(keepDataLabel.snp.left)
        make.trailing.equalTo(-20)
        make.prime.equalTo(keepDataLabel.snp.backside).offset(8)
    }


    //second possibility
    checkImageView2 = UIImageView(picture: nil)
    if let checkImageView2 = checkImageView2 {
        checkImageView2.tintColor = .lightBurgundy
        dataOptionsView.addSubview(checkImageView2)
        checkImageView2.snp.makeConstraints { (make) in
            make.main.equalTo(20)
            make.width.equalTo(20)
            make.top.equalTo(20)
            make.prime.equalTo(keepDataDescLabel.snp.backside).offset(24)
        }
    }

    let deleteDataLabel = UILabel(body: CGRect.zero)
    deleteDataLabel.font = ToshlFont.regularFont(ofSize: 14)
    deleteDataLabel.textColor = .textColor1
    deleteDataLabel.numberOfLines = 0
    deleteDataLabel.textual content = NSLocalizedString("bank_connection_disconnect_delete_data", remark: "")
    dataOptionsView.addSubview(deleteDataLabel)
    deleteDataLabel.snp.makeConstraints { (make) in
        make.left.equalTo(checkImageView2!.snp.proper).offset(12)
        make.trailing.equalTo(-20)
        make.centerY.equalTo(checkImageView2!)

    }

    let deleteDataDescLabel = UILabel(body: CGRect.zero)
    deleteDataDescLabel.font = ToshlFont.regularFont(ofSize: 14)
    deleteDataDescLabel.textColor = .textColor1
    deleteDataDescLabel.numberOfLines = 0
    deleteDataDescLabel.textual content = NSLocalizedString("bank_connection_disconnect_delete_data_desc", remark: "")
    dataOptionsView.addSubview(deleteDataDescLabel)
    deleteDataDescLabel.snp.makeConstraints { (make) in
        make.left.equalTo(deleteDataLabel.snp.left)
        make.trailing.equalTo(-20)
        make.prime.equalTo(deleteDataLabel.snp.backside).offset(8)
        make.backside.equalTo(dataOptionsView.backside).offset(-20)
    }


    let firstOptionOverlayView = UIView(body: CGRect.zero)
    firstOptionOverlayView.backgroundColor = .clear
    dataOptionsView.addSubview(firstOptionOverlayView)
    firstOptionOverlayView.snp.makeConstraints { (make) in
        make.left.proper.equalTo(0)
        make.prime.equalTo(checkImageView!.snp.prime)
        make.backside.equalTo(keepDataDescLabel.snp.backside)
    }

    let secondOptionOverlayView = UIView(body: CGRect.zero)
    secondOptionOverlayView.backgroundColor = .clear
    dataOptionsView.addSubview(secondOptionOverlayView)
    secondOptionOverlayView.snp.makeConstraints { (make) in
        make.left.proper.equalTo(0)
        make.prime.equalTo(checkImageView2!.snp.prime)
        make.backside.equalTo(deleteDataDescLabel.backside)
    }

    let disconnectButton = UIButton(sort: .customized)
    CustomViews.roundedButton(disconnectButton, for: .toshlStyleRed)
    disconnectButton.setTitle(NSLocalizedString("bank_connection_disconnect_title", remark: ""), for: .regular)
    disconnectButton.addTarget(self, motion: #selector(disconnectButtonTapped), for: .touchUpInside)
    contentView.addSubview(disconnectButton)

    disconnectButton.snp.makeConstraints { (make) in
        make.main.equalTo(20)
        make.trailing.equalTo(-20)
        make.top.equalTo(44)
        make.prime.equalTo(dataOptionsView.snp.backside).offset(16)
    }

    let cancelButton = UIButton()
    cancelButton.addTarget(self, motion: #selector(cancelButtonTapped), for: .touchUpInside)
    cancelButton.setTitle(NSLocalizedString("cancel", remark: ""), for: .regular)
    CustomViews.roundedButton(cancelButton, with: UIColor.grayButtonColor, fillBackgroundOnHighlight: true)
    contentView.addSubview(cancelButton)
    cancelButton.snp.makeConstraints { (make) in
        make.main.equalTo(20)
        make.trailing.equalTo(-20)
        make.top.equalTo(44)
        make.prime.equalTo(disconnectButton.snp.backside).offset(16)
        //make.backside.equalTo(contentView.snp.backside).offset(-16) //ALSO THIS DOES NOT WORK

    }
}

Do you see any apparent issues with my constraints?