Skip to content

Multi-day events always stop at the end of each line #116

@asadardiansyah

Description

@asadardiansyah

I created a few simple lines of code just to show some events. I set each event with a duration of 3 days. But the problem is, every time it reaches the end of each line / month, the event always stops. Any ideas what I missed? Thanks in advance!

Here is the preview of the screen:
Screen Shot 2020-10-02 at 01 04 11

class ChartVc: BaseViewController, MGCMonthPlannerViewDataSource, MGCMonthPlannerViewDelegate {
    @IBOutlet weak var monthPlannerView: MGCMonthPlannerView!

    override func viewDidLoad() {
        super.viewDidLoad()
        self.monthPlannerView.dateFormat = "dd"
        self.monthPlannerView.style = .events
        self.monthPlannerView.monthHeaderStyle = .short
        self.monthPlannerView.gridStyle = .default
        
        self.monthPlannerView.pagingMode = .headerTop

        self.monthPlannerView.dataSource = self
        self.monthPlannerView.delegate = self
        
        self.monthPlannerView.backgroundColor = .white
        self.monthPlannerView.canCreateEvents = false
        self.monthPlannerView.canMoveEvents = false
    }
    
    override func viewDidLayoutSubviews() {
        super.viewDidLayoutSubviews()
        self.monthPlannerView.rowHeight = (self.monthPlannerView.height - 200 ) / 5
        self.monthPlannerView.layoutIfNeeded()
    }
    
    func monthPlannerView(_ view: MGCMonthPlannerView!, numberOfEventsAt date: Date!) -> Int {
        if (date.components?.day ?? 1) % 3 == 0 { return 1 }
        return 0
    }
    
    func monthPlannerView(_ view: MGCMonthPlannerView!, dateRangeForEventAt index: UInt, date: Date!) -> MGCDateRange! {
        return MGCDateRange(start: date, end: date.addingTimeInterval(3600 * 48))
    }
    
    func monthPlannerView(_ view: MGCMonthPlannerView!, cellForEventAt index: UInt, date: Date!) -> MGCEventView! {
        let view = MGCStandardEventView()
        view.title = "Haloooo"
        view.color = .randomPastel()
        return view
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions