Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

📅 Calendar for Apple platforms in Swift

License

NotificationsYou must be signed in to change notification settings

richardtop/CalendarKit

Repository files navigation

CalendarKitCalendarKitLicenseSwiftPM compatibleSwift CompatibilityPlatform CompatibilityTagVersion

YouTube Channel SubscribersTwitterGitHub followers

Richard Topchii on Telegram

CalendarKit

CalendarKit is a Swift calendar UI library for iOS and Mac Catalyst. It looks similar to the Apple Calendar app out-of-the-box, while allowing customization when needed. CalendarKit is composed of multiple modules which can be used together or independently.

Tutorials

Need Help?

If you have aprogramming question about how to use CalendarKit in your application, ask it on StackOverflow with theCalendarKit tag.

Check out theSample App for reference.

Create a new Issue from template to report a bug or request a new feature.

Examples

Video

Sample App

Installation

CalendarKit can be installed with Swift Package Manager or with CocoaPods.

Swift Package Manager (Xcode 12 or higher)

The preferred way of installing CalendarKit is via theSwift Package Manager.

  1. In Xcode, open your project and navigate toFileSwift PackagesAdd Package Dependency...
  2. Paste the repository URL (https://github.com/richardtop/CalendarKit.git) and clickNext.
  3. ForRules, selectVersion (Up to Next Major) and clickNext.
  4. ClickFinish.

Adding Package Dependencies to Your App

Usage

  1. SubclassDayViewController
  2. ImplementEventDataSource protocol to show events.

CalendarKit requiresEventDataSource to return an array of objects conforming toEventDescriptor protocol, specifying all the information needed to display a particular event. You're free to use a defaultEvent class as a model or create your own class conforming to theEventDescriptor protocol.

// Return an array of EventDescriptors for particular dateoverridefunc eventsForDate(_ date:Date)->[EventDescriptor]{varmodels= myAppEventStore.getEventsForDate(date) // Get events (models) from the storage / APIvarevents=[Event]()formodelin models{      // Create new EventViewletevent=Event()      // Specify DateInterval      event.dateInterval=DateInterval(start: model.startDate, end: model.endDate)      // Add info: event title, subtitle, location to the array of Stringsvarinfo=[model.title, model.location]      info.append("\(datePeriod.beginning!.format(with:"HH:mm")) -\(datePeriod.end!.format(with:"HH:mm"))")      // Set "text" value of event by formatting all the information needed for display      event.text= info.reduce("",{$0+ $1+"\n"})      events.append(event)}return events}

After receiving an array of events for a particular day, CalendarKit will handle view layout and display.

Usage

To respond to the user input, override mehtods ofDayViewDelegate, for example:

overridefunc dayViewDidSelectEventView(_ eventView:EventView){print("Event has been selected:\(eventview.data)")}overridefunc dayViewDidLongPressEventView(_ eventView:EventView){print("Event has been longPressed:\(eventView.data)")}

Localization

CalendarKit supports localization and uses iOS default locale to display month and day names. First day of the week is also selected according to the iOS locale.

GermanNorwegian

Styles

By default, CalendarKit looks similar to the Apple Calendar app and fully supports Dark Mode. If needed, CalendarKit's look can be easily customized. Steps to apply a custom style are as follows:

  1. Create a newCalendarStyle object (or copy existing one)
  2. Change style by updating the properties.
  3. InvokeupdateStyle method with the newCalendarStyle.
letstyle=CalendarStyle()style.backgroundColor=UIColor.blackdayView.updateStyle(style)

Light themeDark theme

Requirements

  • iOS 11.0+, macOS (Catalyst) 10.15+
  • Swift 5.7+

Contributing

The list of features currently in development can be viewed on theissues page.

Before contributing, please reviewguidelines and code style.

Author

Richard Topchii

License

CalendarKit is available under the MIT license. See the LICENSE file for more info.


[8]ページ先頭

©2009-2026 Movatter.jp