Closed MohamedElgharbawy closed 5 years ago
This is my configureCalendar
:
extension DeadlineViewController: JTACMonthViewDataSource {
func configureCalendar(_ calendar: JTACMonthView) -> ConfigurationParameters {
let formatter = DateFormatter()
formatter.dateFormat = "yyyy MM dd"
let calendar = Calendar.current
let components = calendar.dateComponents([.year, .month, .day], from: Date())
let startDate = formatter.date(from: String(components.year!) + " " + String(components.month!) + " " + String(components.day!))!
if(components.month! > 1) {
let endDate = formatter.date(from: String(components.year!+1) + " " + String(components.month!-1) + " " + String(components.day!))!
return ConfigurationParameters(startDate: startDate, endDate: endDate, numberOfRows: 9)
} else {
let endDate = formatter.date(from: String(components.year!) + " " + String(components.month!+11) + " " + String(components.day!))!
return ConfigurationParameters(startDate: startDate, endDate: endDate, numberOfRows: 9)
}
}
By adding this line, I managed to add more rows to the screen:
monthView.cellSize = CGFloat(Double(self.view.frame.size.width)/5)
However, I can't figure out how to reduce the amount of space between the months?
if you want an example of someone who cloned lots apple calendar functionality, you can check this one for reference --> https://github.com/willard1218/WLAppleCalendar
But for your month space issue, yYou'll have to send me a screenshot of how it looks after you made the adjustment above.
How would I increase the amount of space between the months (screenshot attached)? This is my current configuration:
override func viewDidLoad() {
super.viewDidLoad()
// Position Month View under navigation bar
monthView.frame = CGRect(x: 0, y: (navigationController?.navigationBar.frame.maxY)!, width: UIScreen.main.bounds.width, height: UIScreen.main.bounds.height - (navigationController?.navigationBar.frame.height)! - UIApplication.shared.statusBarFrame.height)
// Allows more rows to be displayed at once
monthView.cellSize = CGFloat(Double(self.view.frame.size.width)/5)
}
func configureCalendar(_ calendar: JTACMonthView) -> ConfigurationParameters {
let formatter = DateFormatter()
formatter.dateFormat = "yyyy MM dd"
let calendar = Calendar.current
let components = calendar.dateComponents([.year, .month, .day], from: Date())
let startDate = formatter.date(from: String(components.year!) + " " + String(components.month!) + " " + String(components.day!))!
if(components.month! > 1) {
let endDate = formatter.date(from: String(components.year!+1) + " " + String(components.month!-1) + " " + String(components.day!))!
return ConfigurationParameters(startDate: startDate, endDate: endDate, generateOutDates: .off)
} else {
let endDate = formatter.date(from: String(components.year!) + " " + String(components.month!+11) + " " + String(components.day!))!
return ConfigurationParameters(startDate: startDate, endDate: endDate, generateOutDates: .off)
}
}
Thanks for the image of what it looks like. Now can you send me an image of What you want the image to look like? That way i can know how to go from what you have to what you need.
The configuration will not help. The config is not the place to setup the layout. Also, Have you tried the sample app attached to this GitHub? With it you can see exactly what customization you need by playing around with the setting on it.
Imagine an empty row of numbers in between the end of the month and the beginning of the month. That's the amount of space I want in between the months. Right now they are right up against each other, which looks a bit confusing.
There are a number of ways you can do it.
But one of the easiest is --> Implement a header of height x. An empty blank header. Would this be ok?
closing issue. Implementing a header will resolve your problem.
(Required) Version Number: 8.0.0
Description
The cell lines are stretched out significantly if the monthView is tall. Here is a screenshot of the issue.
Additional Context
I tried adjusting numberOfRows, but the amount of rows in the screen stayed constant, along with their spacing. I am trying to replicate Apple's official Calendar, where they have multiple months on the screen at once.