返回排行榜

richardtop/CalendarKit

Swiftyoutube.com/watch

📅 Calendar for Apple platforms in Swift

cocoapodsswiftioscalendarios-uiios-calendarios-libios-swiftcalendarkitswift-package-managermacoscatalyst
Star 增长趋势
Star
2.7k
Forks
362
周增长
Issues
33
1k2k
2015年10月2019年5月2022年12月2026年7月
README

CalendarKit CalendarKit License SwiftPM compatible Swift Compatibility Platform Compatibility Tag Version

YouTube Channel Subscribers Twitter GitHub followers

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 a programming question about how to use CalendarKit in your application, ask it on StackOverflow with the CalendarKit tag.

Check out the Sample 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.

Swift Package Manager

  1. In Xcode, open your project and navigate to FileSwift PackagesAdd Package Dependency...
  2. Paste the repository URL (https://github.com/richardtop/CalendarKit.git) and click Next.
  3. For Rules, select Version (Up to Next Major) and click Next.
  4. Click Finish.

Adding Package Dependencies to Your App

Usage

  1. Subclass DayViewController
  2. Implement EventDataSource protocol to show events.

CalendarKit requires EventDataSource to return an array of objects conforming to EventDescriptor protocol, specifying all the information needed to display a particular event. You're free to use a default Event class as a model or create your own class conforming to the EventDescriptor protocol.

// Return an array of EventDescriptors for particular date
override func eventsForDate(_ date: Date) -> [EventDescriptor] {
  var models = myAppEventStore.getEventsForDate(date) // Get events (models) from the storage / API

  var events = [Event]()

  for model in models {
      // Create new EventView
      let event = Event()
      // Specify DateInterval
      event.dateInterval = DateInterval(start: model.startDate, end: model.endDate)
      // Add info: event title, subtitle, location to the array of Strings
      var info = [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 of DayViewDelegate, for example:

override func dayViewDidSelectEventView(_ eventView: EventView) {
  print("Event has been selected: \(eventview.data)")
}

override func 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 new CalendarStyle object (or copy existing one)
  2. Change style by updating the properties.
  3. Invoke updateStyle method with the new CalendarStyle.
let style = CalendarStyle()
style.backgroundColor = UIColor.black
dayView.updateStyle(style)

Light theme Dark theme

Requirements

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

Contributing

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

Before contributing, please review guidelines and code style.

Author

Richard Topchii

License

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

相关仓库
dkhamsing/open-source-ios-apps

:iphone: Collaborative List of Open-Source iOS Apps

Creative Commons Zero v1.0 Universaliosswift
51.3k6k
Alamofire/Alamofire

Elegant HTTP Networking in Swift

SwiftMIT Licensenetworkingurlsession
42.4k7.7k
SDWebImage/SDWebImage

Asynchronous image downloader with cache support as a UIImageView category

Objective-CMIT Licensemacosios
sdwebimage.github.io
25.6k6k
SwiftyJSON/SwiftyJSON

The better way to deal with JSON data in Swift.

SwiftMIT Licenseswiftyjsonjson
22.9k3.4k
SnapKit/SnapKit

A Swift Autolayout DSL for iOS & OS X

SwiftMIT Licenseautoautolayout
snapkit.github.io/SnapKit/
20.3k2k
SwifterSwift/SwifterSwift

A handy collection of more than 500 native Swift extensions to boost your productivity.

SwiftMIT Licenseswiftxcode
swifterswift.com
15.1k1.7k
CocoaPods/CocoaPods

The Cocoa Dependency Manager.

RubyRubyGemsOtheriosdependency-manager
cocoapods.org
14.8k2.7k
CocoaLumberjack/CocoaLumberjack

A fast & simple, yet powerful & flexible logging framework for macOS, iOS, tvOS, watchOS and visionOS

Objective-CBSD 3-Clause "New" or "Revised" Licensemacosios
cocoalumberjack.github.io
13.3k2.3k
SVProgressHUD/SVProgressHUD

A clean and lightweight progress HUD for your iOS and tvOS app.

Objective-CMIT Licenseobjective-chud
github.com/SVProgressHUD/SVProgressHUD
12.5k2.7k
xmartlabs/Eureka

Elegant iOS form builder in Swift

SwiftMIT Licenseiosforms
eurekacommunity.github.io
11.8k1.3k
ninjaprox/NVActivityIndicatorView

A collection of awesome loading animations

SwiftMIT Licenseswiftanimation
10.7k1.2k
WenchaoD/FSCalendar

A fully customizable iOS calendar library, compatible with Objective-C and Swift

Objective-CMIT Licenseswiftobjective-c
10.6k1.9k