@@ -9,8 +9,8 @@ import UIKit
99import SnapKit
1010
1111final class AtchaBallon : UIView {
12- private let topLabel : AtcahaInsetLabel = AtcahaInsetLabel ( )
13- private let bottomLabel : AtcahaInsetLabel = AtcahaInsetLabel ( )
12+ var topLabel : AtcahaInsetLabel = AtcahaInsetLabel ( )
13+ var bottomLabel : AtcahaInsetLabel = AtcahaInsetLabel ( )
1414 private let triangeImageView : UIImageView = UIImageView ( )
1515 private lazy var containerStackView : UIStackView = {
1616 let stackView = UIStackView ( arrangedSubviews: [ topLabel, bottomLabel] )
@@ -184,3 +184,38 @@ final class AtchaBallon: UIView {
184184 }
185185}
186186
187+ extension AtchaBallon {
188+ // 내부 뷰를 초기화 (모두 투명하게)
189+ func resetAndHideAll( ) {
190+ self . layer. removeAllAnimations ( )
191+ self . topLabel. alpha = 0
192+ self . bottomLabel. alpha = 0
193+ self . triangeImageView. alpha = 0
194+ self . isHidden = false
195+ }
196+
197+ // Top 라벨 서서히 표시/숨김
198+ func setTopVisible( _ isVisible: Bool , duration: TimeInterval = 0.3 ) {
199+ self . topLabel. isHidden = false
200+ UIView . animate ( withDuration: duration) {
201+ self . topLabel. alpha = isVisible ? 1 : 0
202+ }
203+ }
204+
205+ // Bottom 라벨(과 삼각형) 서서히 표시/숨김
206+ func setBottomVisible( _ isVisible: Bool , duration: TimeInterval = 0.3 ) {
207+ self . bottomLabel. isHidden = false
208+ UIView . animate ( withDuration: duration) {
209+ self . bottomLabel. alpha = isVisible ? 1 : 0
210+ self . triangeImageView. alpha = isVisible ? 1 : 0
211+ }
212+ }
213+
214+ // 택시비 AttributedString 생성 헬퍼
215+ static func makeFareAttributedString( fareStr: String ) -> NSAttributedString {
216+ let gray = NSMutableAttributedString ( string: " 여기서 막차 놓치면 택시비 " , attributes: [ . foregroundColor: UIColor . gray100] )
217+ let white = NSMutableAttributedString ( string: " 약 \( fareStr) " , attributes: [ . foregroundColor: UIColor . white] )
218+ gray. append ( white)
219+ return gray
220+ }
221+ }
0 commit comments