Skip to content

Instantly share code, notes, and snippets.

@Anik0808
Created September 24, 2022 19:31
Show Gist options
  • Save Anik0808/bfde2c29504875078f8b9dbf6c102323 to your computer and use it in GitHub Desktop.
Save Anik0808/bfde2c29504875078f8b9dbf6c102323 to your computer and use it in GitHub Desktop.
func setupView(){
view.backgroundColor = .black
//setup the scrollView
view.addSubview(parentScrollView)
parentScrollView.fillSuperview()
parentScrollView.contentSize = CGSize(width: DeviceSize.width,
height: DeviceSize.height*2)
//setup the content view
parentScrollView.addSubview(contentView)
contentView.anchorView(left: parentScrollView.leftAnchor,
width: parentScrollView.contentSize.width,
height: parentScrollView.contentSize.height)
//setup content view top anchor
contentViewTopAnchor = contentView.topAnchor.constraint(equalTo: parentScrollView.contentLayoutGuide.topAnchor, constant: 0)
//activate it
contentViewTopAnchor.isActive = true
//setup the header view
contentView.addSubview(headerView)
headerView.anchorView(top: contentView.topAnchor,
left: contentView.leftAnchor,
right: contentView.rightAnchor)
//setup header view height anchor
headerViewHeightAnchor = headerView.heightAnchor.constraint(equalToConstant: 450)
//activate it
headerViewHeightAnchor.isActive = true
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment