Elliotable 1.2.5

Elliotable 1.2.5

Taein_Kim 维护。



  • Taein Kim

Elliotable

Elliotable 是一个简单的生成大学课程表(Timetable)的库。
如果您只添加一门课程,课程时间将自动计算并添加到课程表中。

v1.2.4 新功能

  • 实现了事件代理,数据源代理模式
  • 滚动问题已解决

韩文版本

点击下面的链接查看韩文版本的 README.md。
韩语使用说明

Android 版本

MinTimetable

作者信息

iOS 开发的课程表库
作者:Elliott Kim / 韩国首尔
邮箱: [email protected]
博客:[https://terry-some.tistory.com/ 最新版本:1.2.4 (Cocoapods)

Version Version Version License Platform

截图

肖像/横幅时间表

screenshot

安装

Cocoapods

Elliotable 可通过 Cocoapods 获取,安装时请将以下行添加到您的 Podfile

pod 'Elliotable'

使用方法

课程项结构

courseId : The identifier of the course   
courseName : The name of the course
roomName : The name of the lecture room
courseDay : Weekday of the course
startTime : Start time of course (String type - format : "HH:mm")
endTime : End time of course (String type - format : "HH:mm")
backgroundColor : backgroud color of each course item
(Optional) textColor: Course Item Text Color

如何使用

在您的 Storyboard 中仅添加一个 View 组件。
在检查器框架中,选择视图类并将它设置为 Elliotable
screenshot
这是如何将视图绑定到Swift文件的截图。
screenshot

首先,通过添加以下行导入我的库。

import Elliotable

然后,创建课程并添加到时间表中。

let course_1 = ElliottEvent(courseId: "c0001", courseName: "Operating System", roomName: "IT Building 21204", courseDay: .tuesday, startTime: "12:00", endTime: "13:15", backgroundColor: [UIColor])

let course_2 = ElliottEvent(courseId: "c0002", courseName: "Operating System", roomName: "IT Building 21204", courseDay: .thursday, startTime: "12:00", endTime: "13:15", textColor: UIColor.white, backgroundColor: [UIColor])

最后,定义时间表的属性。

@IBOutlet var elliotable: Elliotable!

委托模式

Elliotable 使用委托模式。

class ViewController : UIViewController, ElliotableDelegate, ElliotableDataSource {

}
// Delegate Pattern  
elliotable.delegate = self  
elliotable.dataSource = self

课程项目应用

要应用课程,请在委托方法中使用 courseItems 方法。

// Set course Items
func courseItems(in elliotable: Elliotable) -> [ElliottEvent] {  
    return courseList  
}  

更新课程项目

如果您更改了课程项目,应该调用 reloadData 函数以允许应用新的数据。

elliotable.reloadData()  

课程项目事件监听器

对于 lecture items 有两个触摸事件,一个是常规触摸事件,另一个是长按触摸事件。

// Course Tap Event  
func elliotable(elliotable: Elliotable, didSelectCourse selectedCourse: ElliottEvent) { }  

// Course Long Press Event  
func elliotable(elliotable: Elliotable, didLongSelectCourse longSelectedCourse : ElliottEvent) { }  

课程项目圆角选项配置

如果您想对 lecture item 处理圆角,可以应用以下选项。

// Course Item Round Option : .none, .all, .left(topLeft, bottomRight), .right(topRight, bottomLeft)
elliotable.roundCorner   = .none

screenshot

日符号定义

private let daySymbol = ["Mon", "Tue", "Wed", "Thu", "Fri"]   

日部分配置

可以使用textPerIndex和numberOfDays参数实现表示星期的部分。

func elliotable(elliotable: Elliotable, at textPerIndex: Int) -> String {  
    return self.daySymbol[textPerIndex]  
}  
  
func numberOfDays(in elliotable: Elliotable) -> Int {  
    return self.daySymbol.count  
}  

边框选项配置

要应用时间表边框属性,您可以按如下方式应用。结果屏幕请参阅截图。

// Full Border Option
elliotable.isFullBorder = true

screenshot

其他时间表属性

// Table Item Properties
elliotable.elliotBackgroundColor = UIColor.white
elliotable.borderWidth        = 1
elliotable.borderColor        = UIColor(red: 0.85, green: 0.85, blue: 0.85, alpha: 1.0)

// Course Item Properties
elliotable.textEdgeInsets = UIEdgeInsets(top: 2, left: 3, bottom: 2, right: 10)
elliotable.courseItemMaxNameLength = 18
elliotable.courseItemTextSize      = 12.5
elliotable.courseTextAlignment     = .left
// Course Item Round Radius
elliotable.borderCornerRadius = 24
elliotable.roomNameFontSize        = 8

// courseItemHeight - default : 60.0
elliottable.courseItemHeight       = 70.0

// Day Symbol & Leftside Time Symbol Properties
elliotable.symbolFontSize = 14
elliotable.symbolTimeFontSize = 12
elliotable.symbolFontColor = UIColor(displayP3Red: 0.1, green: 0.1, blue: 0.1, alpha: 1.0)
elliotable.symbolTimeFontColor = UIColor(displayP3Red: 0.5, green: 0.5, blue: 0.5, alpha: 1.0)
elliotable.symbolBackgroundColor = UIColor(named: "main_bg") ?? .white