Created
March 24, 2020 07:25
-
-
Save Kharauzov/49aa39ce79f511837e52fae2932d45ff to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // This view is a root view inside CardsHolderViewController | |
| class CardsHolderView: UIView { | |
| let topView = UIView() | |
| let cardView1 = CardView() | |
| let cardView2 = CardView() | |
| /// | |
| /// some other code here | |
| /// | |
| private func addSubviews() { | |
| addSubview(topView) | |
| addSubview(cardView1) | |
| addSubview(cardView2) | |
| let screenBounds = UIScreen.main.bounds | |
| // setting card #2 | |
| cardView2.frame = CGRect(x: 0, y: screenBounds.maxY - Constants.closedCardViewHeight, width: screenBounds.width, height: screenBounds.maxY - Constants.minCardTopMargin) | |
| // setting card #1 | |
| cardView1.frame = CGRect(x: 0, y: cardView2.frame.minY - Constants.card1InitialVerticalOffset, width: screenBounds.width, height: screenBounds.maxY - Constants.minCardTopMargin) | |
| // setting top container | |
| topView.frame = CGRect(x: 0, y: 0, width: screenBounds.width, height: cardView1.frame.minY + Constants.subviewBottomOffset) | |
| // perform roundings | |
| cardView1.roundCorners(top: true, cornerRadii: Constants.cardTopCornerRadius) | |
| cardView2.roundCorners(top: true, cornerRadii: Constants.cardTopCornerRadius) | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment