1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
| private func setupUI() { layer.cornerRadius = 4 layer.masksToBounds = true backgroundColor = UIColor.red contentView.addSubview(spaceNameLabel) contentView.addSubview(dateLabel) contentView.addSubview(verticalIndicatorView) contentView.addSubview(timeLabel) contentView.addSubview(rightImageView) NSLayoutConstraint.activate([ spaceNameLabel.topAnchor.constraint(equalTo: contentView.topAnchor, constant: 16), spaceNameLabel.leadingAnchor.constraint(equalTo: contentView.leadingAnchor, constant: 16) ]) NSLayoutConstraint.activate([ dateLabel.bottomAnchor.constraint(equalTo: contentView.bottomAnchor, constant: -12), dateLabel.leadingAnchor.constraint(equalTo: spaceNameLabel.leadingAnchor) ]) NSLayoutConstraint.activate([ verticalIndicatorView.centerYAnchor.constraint(equalTo: dateLabel.centerYAnchor), verticalIndicatorView.leadingAnchor.constraint(equalTo: dateLabel.trailingAnchor, constant: 7.5), verticalIndicatorView.widthAnchor.constraint(equalToConstant: 1), verticalIndicatorView.heightAnchor.constraint(equalToConstant: 8) ]) NSLayoutConstraint.activate([ timeLabel.topAnchor.constraint(equalTo: dateLabel.topAnchor), timeLabel.leadingAnchor.constraint(equalTo: verticalIndicatorView.trailingAnchor, constant: 7.5) ]) NSLayoutConstraint.activate([ rightImageView.trailingAnchor.constraint(equalTo: contentView.trailingAnchor, constant: -18), rightImageView.topAnchor.constraint(equalTo: contentView.topAnchor, constant: 16), rightImageView.widthAnchor.constraint(equalToConstant: 44), rightImageView.heightAnchor.constraint(equalToConstant: 44) ]) }
|