Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
asadardiansyah opened this issue Oct 1, 2020 · 0 comments
Open

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

asadardiansyah opened this issue Oct 1, 2020 · 0 comments

Comments

@asadardiansyah
Copy link

asadardiansyah commented Oct 1, 2020

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant