/
sberpay
/
AgeGate-iOS
Обзор
Документация
Войти
/
sberpay
/
AgeGate-iOS
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
develop
AgeGateExample/Presentation/ConfigModule/Cells/ButtonCell.swift
53 строки
2 KB
SergeyGladkiy
[0.2.0] БДСЧ сценарий
30 июл 2026, 21:57
30 июл 2026, 21:57
cbcdfcb
Код
Авторство
О чём код?
// // ButtonCell.swift // AgeGateExample // // Created by Гладкий Сергей Игоревич on 24.07.2026. // import UIKit final class ButtonCell: UITableViewCell { private var action: (() -> Void)? private lazy var button: UIButton = { let view = UIButton(type: .system) view.titleLabel?.font = .systemFont(ofSize: 15, weight: .medium) view.contentHorizontalAlignment = .leading view.addTarget(self, action: #selector(tapped), for: .touchUpInside) view.translatesAutoresizingMaskIntoConstraints = false return view }() override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { super.init(style: style, reuseIdentifier: reuseIdentifier) selectionStyle = .none setupUI() } required init?(coder: NSCoder) { fatalError("init(coder:) has not been implemented") } func config(title: String, destructive: Bool = false, action: @escaping () -> Void) { button.setTitle(title, for: .normal) button.setTitleColor(destructive ? .systemRed : .systemBlue, for: .normal) self.action = action } @objc private func tapped() { action?() } private func setupUI() { contentView.addSubview(button) NSLayoutConstraint.activate([ button.topAnchor.constraint(equalTo: contentView.topAnchor, constant: 10), button.leadingAnchor.constraint(equalTo: contentView.leadingAnchor, constant: 16), button.trailingAnchor.constraint(equalTo: contentView.trailingAnchor, constant: -16), button.bottomAnchor.constraint(equalTo: contentView.bottomAnchor, constant: -10) ]) } }