patchthecode / JTAppleCalendar

The Unofficial Apple iOS Swift Calendar View. Swift calendar Library. iOS calendar Control. 100% Customizable
https://patchthecode.com
MIT License
7.58k stars 810 forks source link

Cell lines are stretched out very far apart #1107

Closed MohamedElgharbawy closed 5 years ago

MohamedElgharbawy commented 5 years ago

(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.

calendararchitecture

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.

MohamedElgharbawy commented 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)

    }
}
MohamedElgharbawy commented 5 years ago

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?

patchthecode commented 5 years ago

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.

MohamedElgharbawy commented 5 years ago

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)
        }

    }
patchthecode commented 5 years ago
  1. 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.

  2. 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.

MohamedElgharbawy commented 5 years ago

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.

patchthecode commented 5 years ago

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?

patchthecode commented 5 years ago

closing issue. Implementing a header will resolve your problem.