iOS/코드조각
[iOS, Swift] Constraint를 통한 동적 높이 조절
검은참깨두유vm
2022. 10. 8. 10:53
반응형
iOS 15.5, Xcode 13.31, Swift 5, UIKit 환경에서 진행했습니다.

스토리보드에서 작성한 뷰와 Constraint를 코드로 가져와 Constraint 값을 변경하여 동적으로 움직이는 뷰를 만들 수 있습니다.
@IBOutlet var bottomConstraint: NSLayoutConstraint!
@IBAction func didTapContainButton(_ sender: UIButton) {
if bottomConstraint.constant == 500 {
bottomConstraint.constant = 300
} else {
bottomConstraint.constant = 500
}
}

반응형