Swift/UIKit

[UIKit] frame vs bounds

insub4067 2022. 11. 25. 23:26
func add(childVC: UIViewController, to containerView: UIView) {
    addChild(childVC)
    containerView.addSubview(childVC.view)
    childVC.view.frame = containerView.frame
    childVC.didMove(toParent: self)
}
func add(childVC: UIViewController, to containerView: UIView) {
    addChild(childVC)
    containerView.addSubview(childVC.view)
    childVC.view.frame = containerView.bounds
    childVC.didMove(toParent: self)
}

frame - 부모에게 상속받은 좌표값 (화면 전체에서의 위치)
bounds - 자기 자신이 기준