GMCalendar 2.0

GMCalendar 2.0

Gianpiero Mode 维护。



GMCalendar

如果您喜欢这个 pod,请在此页面的右上角给我 star!

Swift License

概述

GMCalendar 是一个可定制的 Swift 写作的 Calendar Pod,如果您需要在 Swift 中使用简单的日历,则可以帮助到您。这是第一个版本,很快将会有一些新功能!

  • 您可以在 storyboard 中实现它或用几行代码实现。
  • 目前有 7 种不同的动画。
  • 它支持不同的尺寸。
  • 很快将会有一些新功能和动画!

如果您想看到实际效果,请查看示例。

预览示例

旋转和缩放 缩放 旋转 其他

如果您发现任何问题,请告诉我。

示例

要运行示例项目,请克隆仓库,然后首先从 Example 目录中运行 pod install

要求

  • Swift 5。
  • iOS 13 或更高版本。

安装

要使用 CocoaPods 将 GMCalendar 集成到您的 Xcode 项目中,您需要在您的 Podfile 中指定它。

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '13.0'
use_frameworks!

pod 'GMCalendar'

然后,运行以下命令

$ pod install

使用

无代码实现

  1. 在您想要日历的视图控制器中创建一个视图,然后将类更改为 GMCalendar

  1. 运行 de App xP

注意:您只能在代码中修改您想要动画

代码实现

  1. 导入 GMCalendar
import GMCalendar
  1. 创建一个 GMCalendar 类型的 View,然后将其作为子视图添加
override func viewDidLoad() {
    super.viewDidLoad()
    
    let calendarView: GMCalendar = GMCalendar(frame: CGRect(x: 20, y: 100, width: 360, height: 360))
    self.view.addSubview(calendarView)   
}
  1. 运行 de App xP

自定义

GMCalendar 支持以下代码修改

@IBInspectable var monthNameVisible: Bool = true
@IBInspectable var borderColor: UIColor = .clear
@IBInspectable var borderWidth: CGFloat = 0
@IBInspectable var cornerRadius: CGFloat = 0
@IBInspectable var task1Color: UIColor = .blue
@IBInspectable var task2Color: UIColor = .red

@IBInspectable var arrowsAvailable: Bool = true
@IBInspectable var rightArrowImage: UIImage? = UIImage(named: "right_arrow")
@IBInspectable var leftArrowImage: UIImage? = UIImage(named: "left_arrow")

@IBInspectable var verticalSwipe: Bool = true
@IBInspectable var horizontalSwipe: Bool = true

@IBInspectable var animation: Bool = true
@IBInspectable var animationDuration: TimeInterval = 0.5

@IBInspectable var colorForDaySelected: UIColor = .red

@IBInspectable var widthForView: CGFloat = 360//260
@IBInspectable var heightForView: CGFloat = 360//300

@IBInspectable public var showWeekends: Bool = false

@IBInspectable public var showCurrentDaySelected: Bool = true

或在 Storyboard 中

您可以使用 DayModel 属性禁用某些日期和为某些日期创建任务。

var notAvailableDays: [DayModel]

var daysWithTasks: [DayModel]

使用 DayModel

struct DayModel{
    var day: Int
    var month: Int
    var year: Int
    var task1: Bool
    var task1Description: String
    var task2: Bool
    var task2Description: String
}
var notAvailableDays: [DayModel] = [
    DayModel(day: 1, month: 2, year: 2020, task1: true, task1Description: "Prueba", task2: true, task2Description: "Prueba 2"),
    DayModel(day: 2, month: 3, year: 2020, task1: true, task1Description: "Prueba", task2: true, task2Description: "Prueba 2"),
    DayModel(day: 3, month: 3, year: 2020, task1: true, task1Description: "Prueba", task2: true, task2Description: "Prueba 2")]

var daysWithTasks: [DayModel] = [
    DayModel(day: 1, month: 2, year: 2020, task1: true, task1Description: "Prueba", task2: true, task2Description: "Prueba 2"),
    DayModel(day: 5, month: 2, year: 2020, task1: true, task1Description: "Prueba", task2: true, task2Description: "Prueba 2"),
    DayModel(day: 7, month: 2, year: 2020, task1: true, task1Description: "Prueba", task2: true, task2Description: "Prueba 2"),
    DayModel(day: 12, month: 2, year: 2020, task1: true, task1Description: "Prueba", task2: true, task2Description: "Prueba 2"),
    DayModel(day: 13, month: 2, year: 2020, task1: true, task1Description: "Prueba", task2: true, task2Description: "Prueba 2"),
    DayModel(day: 20, month: 2, year: 2020, task1: true, task1Description: "Prueba", task2: true, task2Description: "Prueba 2"),
    DayModel(day: 23, month: 2, year: 2020, task1: true, task1Description: "Prueba", task2: false, task2Description: "Prueba 2")]

注意:在当前版本(2.0)中,如果您想的话可以隐藏周末

作者

Giampiero Mode Tw: @GianMode Linkedln: www.linkedin.com/in/gianpiero-mode-a001b6a7

许可协议

GMCalendar可在MIT许可下使用。有关更多信息,请参阅LICENSE文件。