Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auto Layout in Swift: Writing constraints programmatically (Code Base UI) #6

Open
chaneeii opened this issue Jul 14, 2022 · 1 comment
Labels
in-progress 작업중인내용 UIKit UIKit

Comments

@chaneeii chaneeii added UIKit UIKit in-progress 작업중인내용 labels Jul 14, 2022
@chaneeii
Copy link
Owner Author

chaneeii commented Jul 14, 2022

Questions

  • 왜 private let으로 view를 선언해주는가
private let titleImageView: UIImageView = {
        let imageView = UIImageView()
        imageView.translatesAutoresizingMaskIntoConstraints = false
        imageView.image = UIImage(named: "login_title_icon")
        imageView.contentMode = .scaleAspectFit
        return imageView
}()
  • NSLayoutConstraint.activate 을 사용하는 이유
NSLayoutConstraint.activate([
            self.container.leadingAnchor.constraint(equalTo: self.view.leadingAnchor, constant: 50),
            self.container.trailingAnchor.constraint(equalTo: self.view.trailingAnchor, constant: -50),
            self.container.centerYAnchor.constraint(equalTo: self.view.centerYAnchor)
])
  • addArrangedSubview 를 사용하는 이유
 self.container.addArrangedSubview(self.titleImageView) // 컨테이너가 스택뷰이기때문

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in-progress 작업중인내용 UIKit UIKit
Projects
None yet
Development

No branches or pull requests

1 participant