-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
상세 이미지를 담을 stackView에 대한 커스텀 클래스를 생성하여 구현 stackView 내에서 이미지를 순서대로 업데이트 해주기 위해서 빈 imageView를 담게 구현 Issue: #38
- Loading branch information
1 parent
244e6ad
commit 92349cd
Showing
5 changed files
with
71 additions
and
18 deletions.
There are no files selected for viewing
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
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
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
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
42 changes: 42 additions & 0 deletions
42
ios/SideDishApp/SideDishApp/Views/Detail/DetailImagesStackView.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,42 @@ | ||
// | ||
// DetailImagesStackView.swift | ||
// SideDishApp | ||
// | ||
// Created by Cory Kim on 2020/04/28. | ||
// Copyright © 2020 corykim0829. All rights reserved. | ||
// | ||
|
||
import UIKit | ||
|
||
class DetailImagesStackView: UIStackView { | ||
|
||
var imageViews: [UIImageView]! | ||
|
||
override init(frame: CGRect) { | ||
super.init(frame: frame) | ||
} | ||
|
||
required init(coder: NSCoder) { | ||
super.init(coder: coder) | ||
} | ||
|
||
func configureImageViews(count: Int) { | ||
imageViews = Array<UIImageView>.init(repeating: UIImageView(), count: count) | ||
imageViews.forEach { _ in | ||
let imageView = UIImageView() | ||
imageView.contentMode = .scaleAspectFit | ||
imageView.backgroundColor = .red | ||
imageView.clipsToBounds = true | ||
addArrangedSubview(imageView) | ||
} | ||
} | ||
|
||
func updateDetailImages(at index: Int, image: UIImage?) { | ||
guard let image = image else { return } | ||
let imageView = arrangedSubviews[index] as! UIImageView | ||
let imageRatio = image.size.height / image.size.width | ||
imageView.translatesAutoresizingMaskIntoConstraints = false | ||
imageView.heightAnchor.constraint(equalToConstant: frame.width * imageRatio).isActive = true | ||
imageView.image = image | ||
} | ||
} |