-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4749869
commit 175373e
Showing
1 changed file
with
45 additions
and
0 deletions.
There are no files selected for viewing
45 changes: 45 additions & 0 deletions
45
Multimer/Multimer/Presentation/RingtoneSelect/RingtoneViewCell.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// | ||
// RingtoneViewCell.swift | ||
// Multimer | ||
// | ||
// Created by 김상혁 on 2023/08/02. | ||
// | ||
|
||
import UIKit | ||
|
||
final class RingtoneViewCell: UITableViewCell, CellIdentifiable { | ||
|
||
private let titleLabel = UILabel() | ||
|
||
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { | ||
super.init(style: style, reuseIdentifier: reuseIdentifier) | ||
selectionStyle = .none | ||
layoutUI() | ||
} | ||
|
||
@available(*, unavailable) | ||
required init?(coder: NSCoder) { | ||
fatalError("init(coder:) has not been implemented") | ||
} | ||
|
||
func configure(title: String, isSelected: Bool) { | ||
titleLabel.text = title | ||
accessoryType = isSelected ? .checkmark : .none | ||
} | ||
|
||
func toggleSelection() { | ||
accessoryType = isSelected ? .none : .checkmark | ||
} | ||
} | ||
|
||
// MARK: - UI Layout | ||
|
||
private extension RingtoneViewCell { | ||
func layoutUI() { | ||
contentView.addSubview(titleLabel) | ||
|
||
titleLabel.translatesAutoresizingMaskIntoConstraints = false | ||
titleLabel.leadingAnchor.constraint(equalTo: contentView.leadingAnchor, constant: 16).isActive = true | ||
titleLabel.centerYAnchor.constraint(equalTo: contentView.centerYAnchor).isActive = true | ||
} | ||
} |