buguibu / ios-notes-issues-lessons

Notes, issues and lessons about my iOS development experience
2 stars 0 forks source link

Snapkit and programatically created UITableViewCell #22

Open buguibu opened 4 years ago

buguibu commented 4 years ago

    private func setupView() {
        backgroundColor = .clear
        iconView.addSubview(iconImageView)
        contentView.addSubview(iconView)
        contentView.addSubview(userLabel)
        contentView.addSubview(disclosureIndicator)
        setupLayout()
    }

    private func setupLayout() {
        iconView.snp.makeConstraints { maker in
            maker.height.width.equalTo(24)
            maker.left.equalTo(contentView).offset(Constants.defaultMargin)
            maker.top.equalTo(contentView).offset(12)
        }
        userLabel.snp.makeConstraints { maker in
            maker.left.equalTo(iconView.snp_rightMargin).offset(Constants.defaultMargin)
            maker.top.equalTo(contentView).offset(13)
            maker.right.equalTo(disclosureIndicator).offset(-1 * Constants.defaultMargin)
        }
        disclosureIndicator.snp.makeConstraints { maker in
            maker.height.equalTo(13)
            maker.width.equalTo(8)
            maker.top.equalTo(contentView).offset(16)
            maker.right.equalTo(contentView.snp_right).offset(-1 * Constants.defaultMargin)
        }
    }```