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

I want to yearly, weekly and daily calendar view #1426

Open
KaranVakharia789 opened this issue Feb 21, 2024 · 2 comments
Open

I want to yearly, weekly and daily calendar view #1426

KaranVakharia789 opened this issue Feb 21, 2024 · 2 comments

Comments

@KaranVakharia789
Copy link

I attached image there is 3 screen and i want to daily, weekly and yearly calendar view. But customise these view?
Screenshot 2024-02-21 at 4 49 37 PM

@ekoprassetyo
Copy link

hey dude, what library it is?

@pksuthar746
Copy link

To implement yearly, weekly, and daily views in your iOS app using FSCalendar, you'll need to customize the calendar's settings or use a combination of FSCalendar and your custom logic. Here's how you can achieve this:

  1. Yearly View
    FSCalendar doesn't natively support a yearly view, so you can implement it by:
    Creating a collection of months for the year.
    Using a UICollectionView or UITableView to display each month.

Example:
import UIKit
import FSCalendar

class YearlyViewController: UIViewController {
@IBOutlet weak var collectionView: UICollectionView!
// Custom logic to show FSCalendar for each month in a collection view
}
2. Weekly View
FSCalendar can be configured to show a weekly view by adjusting its scope.
Example:
calendar.scope = .week
You can toggle between weekly and monthly views programmatically or using user interactions.
To Animate Scope Change:
calendar.setScope(.week, animated: true)
3. Daily View
For a daily view:
Use FSCalendar's delegate method to highlight and zoom into a specific date.
Alternatively, use a simple label or view for selected days.
Example:
func calendar(_ calendar: FSCalendar, didSelect date: Date, at monthPosition: FSCalendarMonthPosition) {
// Show daily events or activities
print("Selected date: (date)")
}

Full Implementation
You can combine all these views using a segmented control or buttons to toggle between views.

@IBOutlet weak var segmentedControl: UISegmentedControl!

@IBAction func segmentChanged(_ sender: UISegmentedControl) {
switch sender.selectedSegmentIndex {
case 0: // Daily View
calendar.scope = .month
// Filter to show only events for a single day
case 1: // Weekly View
calendar.setScope(.week, animated: true)
case 2: // Yearly View
// Present custom yearly view
presentYearlyView()
default:
break
}
}
Yearly View with UICollectionView
You can implement a yearly view by embedding FSCalendar into each cell of a UICollectionView. Display one calendar per cell and configure it to show a single month.
Let me know if you need a detailed example for any specific 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

3 participants