Making view resize to its parent when added with addSubview

后端 未结 6 631
再見小時候
再見小時候 2020-12-29 21:35

I\'m having a problem when using addSubview.

Example code:

ParentView *myParentView = [[ParentView alloc] initWithNibName:@\"ParentView \" bundle:nil         


        
6条回答
  •  长发绾君心
    2020-12-29 22:17

    Tested in Xcode 9.4, Swift 4 Another way to solve this issue is , You can add

    override func layoutSubviews() {
            self.frame = (self.superview?.bounds)!
        }
    

    in subview class.

提交回复
热议问题