Bibi's DevLog ๐Ÿค“๐ŸŽ

์ฝ”๋“œ๋กœ UIView ๋งŒ๋“ค๊ธฐ ๊ธฐ๋ณธ ํ…œํ”Œ๋ฆฟ ๋ณธ๋ฌธ

๐Ÿ“ฑ๐ŸŽ iOS/Code Templates

์ฝ”๋“œ๋กœ UIView ๋งŒ๋“ค๊ธฐ ๊ธฐ๋ณธ ํ…œํ”Œ๋ฆฟ

๋น„๋น„ bibi 2022. 5. 11. 16:23

import UIKit

class AnyView: UIView {

    static let identifier = "AnyView"

    private let anyLabel: UILabel = {
        var label = UILabel()
        return label
    }()

    override init(frame: CGRect) {
        super.init(frame: frame)
        setUI()
        setConstraint()
    }

    required init?(coder: NSCoder) {
        super.init(coder: coder)
        setUI()
        setConstraint()
    }

    private func setUI() {
        self.addSubview(anyLabel)
    }

    private func setConstraint() {
        // set constraints for all components with individual private functions like below
        configureAnyLabelConstraint()
    }

    private func configureAnyLabelConstraint() {
        anyLabel.translatesAutoresizingMaskIntoConstraints = false
        NSLayoutConstraint.activate([
            // set constraints for anyLabel
        ])
    }
}