image1 UIImageView를 Image 크기에 맞추기 [Swift] 문제점: UIImageView에서 scaleToFit 설정을 준 후, constraint를 통해 width가 화면 뷰에 맞도록 고정시켰다. 하지만 UIImagView의 크기가 줄어들지 않아 남는 여백이 생겨 UIImageView를 Image 크기에 맞게 AutoLayout을 설정하려 한다. 해결법: 1. Image의 비율을 저장한다. 2. AutoLayout의 height 설정에서 저장한 비율을 이용해 UIImageView의 width값으로 height값을 구해 AutoLayout을 설정한다. private let postImageView: UIImageView = { let iv = UIImageView() iv.contentMode = .scaleAspectFit iv.layer.borderWidth.. 2023. 8. 26. 이전 1 다음