Created
March 18, 2020 10:35
-
-
Save codedeman/69b04cbb7345251eb7f5de65d9139e88 to your computer and use it in GitHub Desktop.
layoutwithcode
This file contains 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
// | |
// HomeVC.swift | |
// Animation-Research | |
// | |
// Created by Ominext on 3/18/20. | |
// Copyright © 2020 Ominext. All rights reserved. | |
// | |
import UIKit | |
import SnapKit | |
class HomeVC: UIViewController { | |
let newFeedScroll:UIScrollView = { | |
let scrollView = UIScrollView() | |
scrollView.backgroundColor = .white | |
return scrollView | |
}() | |
let contentView = UIView() | |
let label1: UILabel = { | |
let label = UILabel() | |
label.text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborumLorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborumLorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.............." | |
label.numberOfLines = 0 | |
label.sizeToFit() | |
label.textColor = UIColor.black | |
label.translatesAutoresizingMaskIntoConstraints = false | |
return label | |
}() | |
let label2: UILabel = { | |
let label = UILabel() | |
label.text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat." | |
label.numberOfLines = 0 | |
label.sizeToFit() | |
label.textColor = UIColor.white | |
label.translatesAutoresizingMaskIntoConstraints = false | |
return label | |
}() | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
setupScrollView() | |
setupViews() | |
} | |
func setupScrollView(){ | |
// let navViewController = UINavigationController(rootViewController: HomeVC()) | |
// navigationController?.title = "Bookde" | |
self.navigationController?.title = "Bookde" | |
self.navigationController?.navigationBar.prefersLargeTitles = true | |
newFeedScroll.translatesAutoresizingMaskIntoConstraints = false | |
contentView.translatesAutoresizingMaskIntoConstraints = false | |
view.addSubview(newFeedScroll) | |
newFeedScroll.addSubview(contentView) | |
newFeedScroll.snp.makeConstraints { (make) in | |
make.centerX.equalTo(view.center) | |
make.width.equalTo(self.view) | |
make.top.equalTo(self.view) | |
make.bottom.equalTo(self.view) | |
} | |
contentView.snp.makeConstraints { (make) in | |
make.centerX.equalTo(newFeedScroll) | |
make.width.equalTo(newFeedScroll) | |
make.top.equalTo(newFeedScroll) | |
make.bottom.equalTo(newFeedScroll) | |
} | |
// newFeedScroll.centerXAnchor.constraint(equalTo: view.centerXAnchor).isActive = true | |
// newFeedScroll.widthAnchor.constraint(equalTo: view.widthAnchor).isActive = true | |
// newFeedScroll.topAnchor.constraint(equalTo: view.topAnchor).isActive = true | |
// newFeedScroll.bottomAnchor.constraint(equalTo: view.bottomAnchor).isActive = true | |
// | |
// contentView.centerXAnchor.constraint(equalTo: newFeedScroll.centerXAnchor).isActive = true | |
// contentView.widthAnchor.constraint(equalTo: newFeedScroll.widthAnchor).isActive = true | |
// contentView.topAnchor.constraint(equalTo: newFeedScroll.topAnchor).isActive = true | |
// contentView.bottomAnchor.constraint(equalTo: newFeedScroll.bottomAnchor).isActive = true | |
// | |
} | |
func setupViews(){ | |
contentView.addSubview(label1) | |
label1.centerXAnchor.constraint(equalTo: contentView.centerXAnchor).isActive = true | |
label1.topAnchor.constraint(equalTo: contentView.topAnchor).isActive = true | |
label1.widthAnchor.constraint(equalTo: contentView.widthAnchor, multiplier: 3/4).isActive = true | |
contentView.addSubview(label2) | |
label2.centerXAnchor.constraint(equalTo: contentView.centerXAnchor).isActive = true | |
label2.topAnchor.constraint(equalTo: label1.bottomAnchor, constant: 25).isActive = true | |
label2.widthAnchor.constraint(equalTo: contentView.widthAnchor, multiplier: 3/4).isActive = true | |
label2.bottomAnchor.constraint(equalTo: contentView.bottomAnchor).isActive = true | |
} | |
// func creat)))creatView(){ | |
// | |
// let screensize: CGRect = UIScreen.main.bounds | |
// let screenWidth = screensize.width | |
// let screenHeight = screensize.height | |
// | |
// newFeedScrollView = UIScrollView(frame: CGRect(x: 0, y: 120, width: screenWidth, height: screenHeight)) | |
// newFeedScrollView.contentSize = CGSize(width: screenWidth, height: 2000) | |
// self.view.addSubview(newFeedScrollView) | |
// newFeedScrollView.addSubview(redView) | |
// | |
//// redView.addSubview(blueView) | |
//// newFeedScrollView.verticalScrollIndicatorInsets | |
//// newFeedScrollView.snp.makeConstraints { (make) in | |
//// | |
//// make.leading.equalTo(self.view).inset(0) | |
//// make.trailing.equalTo(self.view).inset(0) | |
//// make.top.equalTo(self.view).inset(0) | |
//// make.bottom.equalTo(self.view).inset(0) | |
//// } | |
// | |
// newFeedScrollView.contentSize = CGSize(width: 360, height: 240) | |
// | |
//// newFeedScrollView.Ad | |
// redView.snp.makeConstraints { (make) in | |
// make.leading.equalTo(self.newFeedScrollView).inset(0) | |
// make.trailing.equalTo(self.newFeedScrollView).inset(0) | |
//// make.top.equalTo(self.newFeedScrollView).inset(0) | |
// make.height.equalTo(50) | |
//// make.width.equalTo(self.newFeedScrollView) | |
// } | |
// | |
// redView.snp.makeConstraints { (make) in | |
// make.leading.equalTo(self.redView).inset(0) | |
// make.trailing.equalTo(self.redView).inset(0) | |
// make.top.equalTo(self.redView).inset(0) | |
// make.height.equalTo(100) | |
//// make.height.equalTo(self.newFeedScrollView) | |
//// make.width.equalTo(self.newFeedScrollView) | |
// } | |
// | |
// | |
} | |
/* | |
// MARK: - Navigation | |
// In a storyboard-based application, you will often want to do a little preparation before navigation | |
override func prepare(for segue: UIStoryboardSegue, sender: Any?) { | |
// Get the new view controller using segue.destination. | |
// Pass the selected object to the new view controller. | |
} | |
*/ | |
This file contains 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
// | |
// HomeVC.swift | |
// Animation-Research | |
// | |
// Created by Ominext on 3/18/20. | |
// Copyright © 2020 Ominext. All rights reserved. | |
// | |
import UIKit | |
import SnapKit | |
class HomeVC: UIViewController { | |
let newFeedScroll:UIScrollView = { | |
let scrollView = UIScrollView() | |
scrollView.backgroundColor = .white | |
return scrollView | |
}() | |
let contentView = UIView() | |
let label1: UILabel = { | |
let label = UILabel() | |
label.text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborumLorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborumLorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.............." | |
label.numberOfLines = 0 | |
label.sizeToFit() | |
label.textColor = UIColor.black | |
label.translatesAutoresizingMaskIntoConstraints = false | |
return label | |
}() | |
let label2: UILabel = { | |
let label = UILabel() | |
label.text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat." | |
label.numberOfLines = 0 | |
label.sizeToFit() | |
label.textColor = UIColor.white | |
label.translatesAutoresizingMaskIntoConstraints = false | |
return label | |
}() | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
setupScrollView() | |
setupViews() | |
} | |
func setupScrollView(){ | |
// let navViewController = UINavigationController(rootViewController: HomeVC()) | |
// navigationController?.title = "Bookde" | |
self.navigationController?.title = "Bookde" | |
self.navigationController?.navigationBar.prefersLargeTitles = true | |
newFeedScroll.translatesAutoresizingMaskIntoConstraints = false | |
contentView.translatesAutoresizingMaskIntoConstraints = false | |
view.addSubview(newFeedScroll) | |
newFeedScroll.addSubview(contentView) | |
newFeedScroll.snp.makeConstraints { (make) in | |
make.centerX.equalTo(view.center) | |
make.width.equalTo(self.view) | |
make.top.equalTo(self.view) | |
make.bottom.equalTo(self.view) | |
} | |
contentView.snp.makeConstraints { (make) in | |
make.centerX.equalTo(newFeedScroll) | |
make.width.equalTo(newFeedScroll) | |
make.top.equalTo(newFeedScroll) | |
make.bottom.equalTo(newFeedScroll) | |
} | |
// newFeedScroll.centerXAnchor.constraint(equalTo: view.centerXAnchor).isActive = true | |
// newFeedScroll.widthAnchor.constraint(equalTo: view.widthAnchor).isActive = true | |
// newFeedScroll.topAnchor.constraint(equalTo: view.topAnchor).isActive = true | |
// newFeedScroll.bottomAnchor.constraint(equalTo: view.bottomAnchor).isActive = true | |
// | |
// contentView.centerXAnchor.constraint(equalTo: newFeedScroll.centerXAnchor).isActive = true | |
// contentView.widthAnchor.constraint(equalTo: newFeedScroll.widthAnchor).isActive = true | |
// contentView.topAnchor.constraint(equalTo: newFeedScroll.topAnchor).isActive = true | |
// contentView.bottomAnchor.constraint(equalTo: newFeedScroll.bottomAnchor).isActive = true | |
// | |
} | |
func setupViews(){ | |
contentView.addSubview(label1) | |
label1.centerXAnchor.constraint(equalTo: contentView.centerXAnchor).isActive = true | |
label1.topAnchor.constraint(equalTo: contentView.topAnchor).isActive = true | |
label1.widthAnchor.constraint(equalTo: contentView.widthAnchor, multiplier: 3/4).isActive = true | |
contentView.addSubview(label2) | |
label2.centerXAnchor.constraint(equalTo: contentView.centerXAnchor).isActive = true | |
label2.topAnchor.constraint(equalTo: label1.bottomAnchor, constant: 25).isActive = true | |
label2.widthAnchor.constraint(equalTo: contentView.widthAnchor, multiplier: 3/4).isActive = true | |
label2.bottomAnchor.constraint(equalTo: contentView.bottomAnchor).isActive = true | |
} | |
// func creat)))creatView(){ | |
// | |
// let screensize: CGRect = UIScreen.main.bounds | |
// let screenWidth = screensize.width | |
// let screenHeight = screensize.height | |
// | |
// newFeedScrollView = UIScrollView(frame: CGRect(x: 0, y: 120, width: screenWidth, height: screenHeight)) | |
// newFeedScrollView.contentSize = CGSize(width: screenWidth, height: 2000) | |
// self.view.addSubview(newFeedScrollView) | |
// newFeedScrollView.addSubview(redView) | |
// | |
//// redView.addSubview(blueView) | |
//// newFeedScrollView.verticalScrollIndicatorInsets | |
//// newFeedScrollView.snp.makeConstraints { (make) in | |
//// | |
//// make.leading.equalTo(self.view).inset(0) | |
//// make.trailing.equalTo(self.view).inset(0) | |
//// make.top.equalTo(self.view).inset(0) | |
//// make.bottom.equalTo(self.view).inset(0) | |
//// } | |
// | |
// newFeedScrollView.contentSize = CGSize(width: 360, height: 240) | |
// | |
//// newFeedScrollView.Ad | |
// redView.snp.makeConstraints { (make) in | |
// make.leading.equalTo(self.newFeedScrollView).inset(0) | |
// make.trailing.equalTo(self.newFeedScrollView).inset(0) | |
//// make.top.equalTo(self.newFeedScrollView).inset(0) | |
// make.height.equalTo(50) | |
//// make.width.equalTo(self.newFeedScrollView) | |
// } | |
// | |
// redView.snp.makeConstraints { (make) in | |
// make.leading.equalTo(self.redView).inset(0) | |
// make.trailing.equalTo(self.redView).inset(0) | |
// make.top.equalTo(self.redView).inset(0) | |
// make.height.equalTo(100) | |
//// make.height.equalTo(self.newFeedScrollView) | |
//// make.width.equalTo(self.newFeedScrollView) | |
// } | |
// | |
// | |
} | |
/* | |
// MARK: - Navigation | |
// In a storyboard-based application, you will often want to do a little preparation before navigation | |
override func prepare(for segue: UIStoryboardSegue, sender: Any?) { | |
// Get the new view controller using segue.destination. | |
// Pass the selected object to the new view controller. | |
} | |
*/ | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment