TestsTested | ✗ |
LangLanguage | SwiftSwift |
License | MIT |
ReleasedLast Release | May 2017 |
SwiftSwift Version | 3.0 |
SPMSupports SPM | ✗ |
Maintained by 黄帅.
Depends on: | |
SnapKit | ~> 3.0 |
MJRefresh | >= 0 |
School ScheduleView for iOS, pure swift.
target 'ProjectName' do
use_frameworks!
pod 'SScheduleView'
end
run pod install
at Example
folder before run the demo.
Direct drag IB to UIView, set the UIView class to SScheduleView,the code section only needs to achieve. See more detail on the demo.
import SScheduleView
scheduleView = SScheduleView()
view.addSubview(scheduleView)
scheduleView { (make) in
make.top.equalTo(self.view).offset(44)
make.left.right.bottom.equalTo(self.view)
}
scheduleView.delegate = self
The application’s data type should implement the SScheduleViewModelProtocol
protocol
public protocol SScheduleViewModelProtocol {
// 周几的课 从1开始
func getDay() -> Int
// 第几节课 从1开始
func getJieci() -> Int
//一节课的持续时间
func getSpan() -> Int
func getCourseName() -> String
func getClassRoom() -> String
// 课程的自定义颜色,若nil则采用随机颜色
func getBackColor() -> UIColor?
}
After that, call the update data function to display the lesson data
var thisWeekCourse = Array<SScheduleViewModelProtocol>()
scheduleView.updateCourseView(courseDataList: thisWeekCourse)
See more detail from the Example project
public protocol SScheduleViewDelegate:class {
func tapCourse(courseModel:SScheduleViewModelProtocol)
func swipeGestureRight()
func swipeGestureLeft()
func pullAHScheduleScrollViewStartRefreshing(_ scheduleScrollView:SScheduleScrollView)
}
/// 其他列宽度 与 第一列宽度 比
@IBInspectable var sideColWidthRatio:CGFloat = 2
/// 顶部日期栏 View 背景色
@IBInspectable var headViewBackgroundColor: UIColor = SScheduleTheme.BlankAreaColor
/// 侧边时间栏 View 背景色
@IBInspectable var sideViewBackgroundColor: UIColor = SScheduleTheme.BlankAreaColor
/// 设置一周显示的天数
open func setShowTotalDay(with num:CGFloat)
/// 设置显示周数
open func setShowWeek(with num:Int)
/// 设置是否显示当前周数,因为有的ViewController在NavigationBar显示当前周数
open func setWeekIsShow(with isShow:Bool)
/// 当前学期开学时间 "yyyy-MM-dd"
open func setTermStartDate(with dateString:String)
/// 清空课表数据,可用于账户退出登录后的操作
open func clearOldCourseView()
extension viewController:UIViewControllerPreviewingDelegate {
public func previewingContext(_ previewingContext: UIViewControllerPreviewing, viewControllerForLocation location: CGPoint) -> UIViewController? {
if let model = scheduleView.getDataModel(with: self.view.convert(location, to: self.scheduleView)) {
// return previewVC
}
return nil
}
public func previewingContext(_ previewingContext: UIViewControllerPreviewing, commit viewControllerToCommit: UIViewController) {
show(viewControllerToCommit, sender: self)
}
}
You are welcome to fork and submit pull requests.
SScheduleView is available under the MIT license. See the LICENSE file for more info.