Skip to content

EmptyView

Hiju edited this page Dec 1, 2021 · 1 revision
import UIKit

final class EmptyView: UIView {
    // MARK: - Properties
    private let imageView = UIImageView()
    private let titlelabel = UILabel()

    // MARK: - Init
    override init(frame: CGRect) {
        super.init(frame: frame)
        configureLayout()
    }

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

    // MARK: - Functions
    private func configureLayout() {
        addSubview(imageView)
        addSubview(titlelabel)
        imageView.translatesAutoresizingMaskIntoConstraints = false
        imageView.centerXAnchor.constraint(equalTo: self.centerXAnchor).isActive = true
        imageView.centerYAnchor.constraint(equalTo: self.centerYAnchor, constant: -50).isActive = true
        imageView.widthAnchor.constraint(equalToConstant: self.frame.width / 5).isActive = true
        imageView.heightAnchor.constraint(equalToConstant: self.frame.width / 5).isActive = true
        titlelabel.translatesAutoresizingMaskIntoConstraints = false
        titlelabel.centerXAnchor.constraint(equalTo: self.centerXAnchor).isActive = true
        titlelabel.topAnchor.constraint(equalTo: imageView.bottomAnchor, constant: 40).isActive = true
    }

    func apply(title: String, image: UIImage) {
        imageView.image = image
        imageView.contentMode = .scaleAspectFit
        imageView.tintColor = .boosterGray
        
        titlelabel.text = title
        titlelabel.textColor = .boosterGray
        titlelabel.numberOfLines = 3
        titlelabel.textAlignment = .center
        titlelabel.font = .notoSansKR(.regular, 17)
    }
}

예시 사진

  • 뷰의 center에 사진과 아래 레이블로 아무것도 없을 때 명시를 해줄 수 있습니다.
  • apply 메소드를 이용하여 사진과 레이블을 넣을 수 있습니다.

Booster🚀🔥

Info

Rule

Backlog

공통 모듈

구현 설명 및 기능 정리

Architecture

Architecture

회의록 & DailyScrum & 회고록

멘토링 피드백

멘토링 피드백
Clone this wiki locally