diff --git a/ParentAssistant/ParentAssistant.xcodeproj/project.pbxproj b/ParentAssistant/ParentAssistant.xcodeproj/project.pbxproj index 5762f31..5debdb7 100644 --- a/ParentAssistant/ParentAssistant.xcodeproj/project.pbxproj +++ b/ParentAssistant/ParentAssistant.xcodeproj/project.pbxproj @@ -41,6 +41,9 @@ AD34D11A2064C79D00989F8D /* MoralDetailCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = AD34D1192064C79D00989F8D /* MoralDetailCell.swift */; }; AD34D11C2064C7AE00989F8D /* EducationDetailCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = AD34D11B2064C7AE00989F8D /* EducationDetailCell.swift */; }; AD34D11E2064C7C300989F8D /* BehaviorDetailCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = AD34D11D2064C7C300989F8D /* BehaviorDetailCell.swift */; }; + AD4BA4A920819AB000F83F13 /* ReportHeaderView.swift in Sources */ = {isa = PBXBuildFile; fileRef = AD4BA4A820819AB000F83F13 /* ReportHeaderView.swift */; }; + AD4BA4AC20819CAD00F83F13 /* ReportHeaderCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = AD4BA4AA20819CAD00F83F13 /* ReportHeaderCollectionViewCell.swift */; }; + AD4BA4AD20819CAD00F83F13 /* ReportHeaderCollectionViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = AD4BA4AB20819CAD00F83F13 /* ReportHeaderCollectionViewCell.xib */; }; AD5681CA208044860034A948 /* GrowCheckUpTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = AD5681C8208044860034A948 /* GrowCheckUpTableViewCell.swift */; }; AD5681CB208044860034A948 /* GrowCheckUpTableViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = AD5681C9208044860034A948 /* GrowCheckUpTableViewCell.xib */; }; AD5681CE2080449A0034A948 /* GrowCheckDownTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = AD5681CC2080449A0034A948 /* GrowCheckDownTableViewCell.swift */; }; @@ -80,7 +83,6 @@ BF388480205CDFBE00A240EF /* WebKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BF38847F205CDFBE00A240EF /* WebKit.framework */; }; BF388482205F5BC800A240EF /* MessageManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = BF388481205F5BC800A240EF /* MessageManager.swift */; }; BF3B8298204FC80D002078EA /* UMCommon.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BF3B8297204FC80D002078EA /* UMCommon.framework */; }; - BF3B82A02050CC8B002078EA /* ReportHeaderView.swift in Sources */ = {isa = PBXBuildFile; fileRef = BF3B829F2050CC8B002078EA /* ReportHeaderView.swift */; }; BF406CD62057B03A000A6681 /* MessageViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = BF406CD52057B03A000A6681 /* MessageViewController.swift */; }; BF406CD82057B529000A6681 /* MessageTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = BF406CD72057B529000A6681 /* MessageTableViewCell.swift */; }; BF406CDA2057BEB8000A6681 /* OrderDetailModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = BF406CD92057BEB8000A6681 /* OrderDetailModel.swift */; }; @@ -207,6 +209,9 @@ AD34D1192064C79D00989F8D /* MoralDetailCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MoralDetailCell.swift; sourceTree = ""; }; AD34D11B2064C7AE00989F8D /* EducationDetailCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EducationDetailCell.swift; sourceTree = ""; }; AD34D11D2064C7C300989F8D /* BehaviorDetailCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BehaviorDetailCell.swift; sourceTree = ""; }; + AD4BA4A820819AB000F83F13 /* ReportHeaderView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReportHeaderView.swift; sourceTree = ""; }; + AD4BA4AA20819CAD00F83F13 /* ReportHeaderCollectionViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReportHeaderCollectionViewCell.swift; sourceTree = ""; }; + AD4BA4AB20819CAD00F83F13 /* ReportHeaderCollectionViewCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = ReportHeaderCollectionViewCell.xib; sourceTree = ""; }; AD5681C8208044860034A948 /* GrowCheckUpTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GrowCheckUpTableViewCell.swift; sourceTree = ""; }; AD5681C9208044860034A948 /* GrowCheckUpTableViewCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = GrowCheckUpTableViewCell.xib; sourceTree = ""; }; AD5681CC2080449A0034A948 /* GrowCheckDownTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GrowCheckDownTableViewCell.swift; sourceTree = ""; }; @@ -246,7 +251,6 @@ BF38847F205CDFBE00A240EF /* WebKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = WebKit.framework; path = System/Library/Frameworks/WebKit.framework; sourceTree = SDKROOT; }; BF388481205F5BC800A240EF /* MessageManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MessageManager.swift; sourceTree = ""; }; BF3B8297204FC80D002078EA /* UMCommon.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UMCommon.framework; path = Pods/UMCCommon/UMCommon.framework; sourceTree = ""; }; - BF3B829F2050CC8B002078EA /* ReportHeaderView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReportHeaderView.swift; sourceTree = ""; }; BF406CD52057B03A000A6681 /* MessageViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MessageViewController.swift; sourceTree = ""; }; BF406CD72057B529000A6681 /* MessageTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MessageTableViewCell.swift; sourceTree = ""; }; BF406CD92057BEB8000A6681 /* OrderDetailModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OrderDetailModel.swift; sourceTree = ""; }; @@ -585,8 +589,10 @@ BF3B829E2050CC7E002078EA /* View */ = { isa = PBXGroup; children = ( - BF3B829F2050CC8B002078EA /* ReportHeaderView.swift */, ADF159602069E00000A9485D /* CalendarView.swift */, + AD4BA4A820819AB000F83F13 /* ReportHeaderView.swift */, + AD4BA4AA20819CAD00F83F13 /* ReportHeaderCollectionViewCell.swift */, + AD4BA4AB20819CAD00F83F13 /* ReportHeaderCollectionViewCell.xib */, ADC9AB75207C65FC00348EF1 /* GrowSubjectCell.swift */, ADC9AB76207C65FC00348EF1 /* GrowSubjectCell.xib */, AD65FB77206354220052415B /* MoralTableViewCell.swift */, @@ -939,6 +945,7 @@ BF67F3BD20590A2F002FDC61 /* Info-OSX.plist in Resources */, BF621CAC205660E90040D2C1 /* My.storyboard in Resources */, BF67F3BC20590A2F002FDC61 /* Info-iOS.plist in Resources */, + AD4BA4AD20819CAD00F83F13 /* ReportHeaderCollectionViewCell.xib in Resources */, AD64A2C5207F28EB00B25E80 /* ProgramVacateBodyTableViewCell.xib in Resources */, BF7A4C84204E338500460463 /* Assets.xcassets in Resources */, BF7A4C85204E338500460463 /* LaunchScreen.storyboard in Resources */, @@ -1036,7 +1043,6 @@ BFEAAAD620525D620072FAAF /* LxButton.m in Sources */, 5993652C20528D5700C8B371 /* MainViewController.swift in Sources */, 5993652A2052553900C8B371 /* pinyin.c in Sources */, - BF3B82A02050CC8B002078EA /* ReportHeaderView.swift in Sources */, BFF9B7EF20577CD300F39B3E /* MyChildrenTableViewCell.swift in Sources */, 590944E22057DA73004478B5 /* utils.swift in Sources */, BFEAAAC9205257460072FAAF /* NSDate+GFCalendar.m in Sources */, @@ -1056,6 +1062,7 @@ 5980BF682061048A00F4A35E /* LZCityPickerController.m in Sources */, AD198173207D9FB4009AB8B5 /* ProgramCheckViewController.swift in Sources */, BFCED88B20528DE700055373 /* MyViewControllerModel.swift in Sources */, + AD4BA4A920819AB000F83F13 /* ReportHeaderView.swift in Sources */, BFF9B7E92056852A00F39B3E /* RegisterViewController.swift in Sources */, BFBC06C72063AE8900CCFAFF /* ZLaunchAdButton.swift in Sources */, ADAEA3982064960300A47D2C /* SceneDetailViewController.swift in Sources */, @@ -1069,6 +1076,7 @@ BFEAAAD720525D620072FAAF /* UIColor+Expanded.m in Sources */, BFF9B7ED2057776100F39B3E /* MyChildrenViewController.swift in Sources */, BFEAAAC1205257460072FAAF /* LXCalendarDayModel.m in Sources */, + AD4BA4AC20819CAD00F83F13 /* ReportHeaderCollectionViewCell.swift in Sources */, 599364EF204E62E700C8B371 /* MyTableViewCell.swift in Sources */, BFF9B7EB205772E100F39B3E /* GetBackPasswordViewController.swift in Sources */, BFF9B7F22057A28900F39B3E /* TableEmptyView.swift in Sources */, diff --git a/ParentAssistant/ParentAssistant.xcodeproj/xcuserdata/caoyang.xcuserdatad/xcschemes/xcschememanagement.plist b/ParentAssistant/ParentAssistant.xcodeproj/xcuserdata/caoyang.xcuserdatad/xcschemes/xcschememanagement.plist index 449940c..d073d4a 100644 --- a/ParentAssistant/ParentAssistant.xcodeproj/xcuserdata/caoyang.xcuserdatad/xcschemes/xcschememanagement.plist +++ b/ParentAssistant/ParentAssistant.xcodeproj/xcuserdata/caoyang.xcuserdatad/xcschemes/xcschememanagement.plist @@ -7,7 +7,7 @@ ParentAssistant.xcscheme orderHint - 9 + 1 diff --git a/ParentAssistant/ParentAssistant.xcworkspace/xcuserdata/caoyang.xcuserdatad/UserInterfaceState.xcuserstate b/ParentAssistant/ParentAssistant.xcworkspace/xcuserdata/caoyang.xcuserdatad/UserInterfaceState.xcuserstate index 27d371b..9bba17d 100644 Binary files a/ParentAssistant/ParentAssistant.xcworkspace/xcuserdata/caoyang.xcuserdatad/UserInterfaceState.xcuserstate and b/ParentAssistant/ParentAssistant.xcworkspace/xcuserdata/caoyang.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/ParentAssistant/ParentAssistant/Classes/controllers/Grow/GrowViewController.swift b/ParentAssistant/ParentAssistant/Classes/controllers/Grow/GrowViewController.swift index ce7f559..42be16b 100644 --- a/ParentAssistant/ParentAssistant/Classes/controllers/Grow/GrowViewController.swift +++ b/ParentAssistant/ParentAssistant/Classes/controllers/Grow/GrowViewController.swift @@ -194,7 +194,6 @@ class GrowViewController: UIViewController,UIScrollViewDelegate { let offsetX = scrollView.contentOffset.x let index = Int(offsetX/getScreenWidth()) let btn = titleBtnArr[index] - clickTitleAction(btn: btn) } } diff --git a/ParentAssistant/ParentAssistant/Classes/controllers/Grow/Report/ReportViewController.swift b/ParentAssistant/ParentAssistant/Classes/controllers/Grow/Report/ReportViewController.swift index 61b98f2..3a8aff5 100644 --- a/ParentAssistant/ParentAssistant/Classes/controllers/Grow/Report/ReportViewController.swift +++ b/ParentAssistant/ParentAssistant/Classes/controllers/Grow/Report/ReportViewController.swift @@ -38,19 +38,20 @@ class ReportViewController: UIViewController,UITableViewDelegate,UITableViewData // MARK: - 设置日期View func setupDateView(){ - let headView = UIView.init(frame: CGRect.init(x: 0, y: 0, width: screenWidth, height: 60)) + let headView = ReportHeaderView.init(frame: CGRect.init(x: 0, y: 0, width: screenWidth, height: 60)) + self.view.addSubview(headView) //添加手势 let recognizer = UISwipeGestureRecognizer.init(target: self, action: #selector(showView)) recognizer.direction = UISwipeGestureRecognizerDirection.down headView.addGestureRecognizer(recognizer) - calendar = CalendarView.init(frame: CGRect.init(x: 0, y: 30, width: screenWidth, height: 260)) + calendar = CalendarView.init(frame: CGRect.init(x: 0, y: 32, width: screenWidth, height: 280)) } @objc func showView(){ keyWindow = UIApplication.shared.keyWindow! - let backBtn = UIButton.init(frame: CGRect.init(x: 0, y: calendar.frame.origin.y+260+22, width: screenWidth, height: screenHeight)) + let backBtn = UIButton.init(frame: CGRect.init(x: 0, y: calendar.frame.origin.y+280+22, width: screenWidth, height: screenHeight)) backBtn.backgroundColor = UIColor.black backBtn.alpha = 0.4 diff --git a/ParentAssistant/ParentAssistant/Classes/controllers/Grow/View/CalendarView.swift b/ParentAssistant/ParentAssistant/Classes/controllers/Grow/View/CalendarView.swift index 2192eea..45f7c9b 100644 --- a/ParentAssistant/ParentAssistant/Classes/controllers/Grow/View/CalendarView.swift +++ b/ParentAssistant/ParentAssistant/Classes/controllers/Grow/View/CalendarView.swift @@ -12,6 +12,9 @@ class CalendarView: UIView,UICollectionViewDelegate,UICollectionViewDataSource { var weekLab = ["日","一","二","三","四","五","六"] + var firstDay = Int() + var monthDay = Int() + var todayDay = Int() override init(frame: CGRect) { super.init(frame: frame) @@ -19,9 +22,11 @@ class CalendarView: UIView,UICollectionViewDelegate,UICollectionViewDataSource { } func drawCalendarView(frame:CGRect) { - //TODO: 数据源待完成 - let dayLab = ["1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19","20","21","22","23","24","25","26","27","28","29","30","31"] - weekLab.append(contentsOf: dayLab) + + + self.firstDay = CalendarDateManager.shared.getFirstMonthDays() + self.monthDay = CalendarDateManager.shared.getCurrentMonthDay() + self.todayDay = CalendarDateManager.shared.getTodayDate() //设置layout let flowlayout = UICollectionViewFlowLayout() flowlayout.itemSize = CGSize.init(width: screenWidth/7, height:40) @@ -41,21 +46,43 @@ class CalendarView: UIView,UICollectionViewDelegate,UICollectionViewDataSource { //MARK: - Delegate func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { - return weekLab.count + return weekLab.count + monthDay + firstDay - 1 } func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "calendarCell", for: indexPath) let lab = UILabel.init(frame: cell.bounds) - lab.text = weekLab[indexPath.row] + + if indexPath.row < weekLab.count { + lab.text = weekLab[indexPath.row] + }else{ + // 超出这个月显示为空 + if indexPath.row+1 >= firstDay+7 && indexPath.row < monthDay+7+firstDay { + lab.text = "\(indexPath.row+1-firstDay-7+1)" + }else{ + lab.text = "" + } + } + // 设置日期颜色 + if indexPath.row+1 > todayDay+7+firstDay-1{ + lab.textColor = UIColor.gray + }else + if indexPath.row+1 == todayDay+7+firstDay-1 { + lab.textColor = UIColor.red + }else{ + lab.textColor = UIColor.black + } + lab.textAlignment = .center cell.addSubview(lab) return cell } func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { - print("点击了 第 \(weekLab[indexPath.row])") + if indexPath.row >= firstDay-1+7 && indexPath.row < todayDay+7+firstDay-1 { + print("点击了 ...\(indexPath.row+1-7-firstDay+1)号") + } } required init?(coder aDecoder: NSCoder) { fatalError("init(coder:) has not been implemented") diff --git a/ParentAssistant/ParentAssistant/Classes/controllers/Grow/View/ReportHeaderCollectionViewCell.swift b/ParentAssistant/ParentAssistant/Classes/controllers/Grow/View/ReportHeaderCollectionViewCell.swift new file mode 100644 index 0000000..cf352c2 --- /dev/null +++ b/ParentAssistant/ParentAssistant/Classes/controllers/Grow/View/ReportHeaderCollectionViewCell.swift @@ -0,0 +1,42 @@ +// +// ReportHeaderCollectionViewCell.swift +// ParentAssistant +// +// Created by Cao yang on 2018/4/14. +// Copyright © 2018年 HANGZHOUTEAM. All rights reserved. +// + +import UIKit + +class ReportHeaderCollectionViewCell: UICollectionViewCell { + + @IBOutlet weak var weekLab: UILabel! + @IBOutlet weak var dataLab: UILabel! + override func awakeFromNib() { + super.awakeFromNib() + // Initialization code + } + func setCellData(index:IndexPath){ + if index.row%7 == 0 || index.row == 0 { + self.weekLab.text = "日" + } + if index.row == 1 || index.row%7 == 1 { + self.weekLab.text = "一" + } + if index.row == 2 || index.row%7 == 2 { + self.weekLab.text = "二" + } + if index.row == 3 || index.row%7 == 3 { + self.weekLab.text = "三" + } + if index.row == 4 || index.row%7 == 4 { + self.weekLab.text = "四" + } + if index.row == 5 || index.row%7 == 5 { + self.weekLab.text = "五" + } + if index.row == 6 || index.row%7 == 6 { + self.weekLab.text = "六" + } + } +} diff --git a/ParentAssistant/ParentAssistant/Classes/controllers/Grow/View/ReportHeaderCollectionViewCell.xib b/ParentAssistant/ParentAssistant/Classes/controllers/Grow/View/ReportHeaderCollectionViewCell.xib new file mode 100644 index 0000000..46c81f4 --- /dev/null +++ b/ParentAssistant/ParentAssistant/Classes/controllers/Grow/View/ReportHeaderCollectionViewCell.xib @@ -0,0 +1,51 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ParentAssistant/ParentAssistant/Classes/controllers/Grow/View/ReportHeaderView.swift b/ParentAssistant/ParentAssistant/Classes/controllers/Grow/View/ReportHeaderView.swift index 09bdf8f..fd4392c 100644 --- a/ParentAssistant/ParentAssistant/Classes/controllers/Grow/View/ReportHeaderView.swift +++ b/ParentAssistant/ParentAssistant/Classes/controllers/Grow/View/ReportHeaderView.swift @@ -2,47 +2,141 @@ // ReportHeaderView.swift // ParentAssistant // -// Created by 葛建军 on 2018/3/8. +// Created by Cao yang on 2018/4/14. // Copyright © 2018年 HANGZHOUTEAM. All rights reserved. // import UIKit -class ReportHeaderView: UIView { - var delegate:ReportHeaderViewDelegate! - @IBOutlet var nameButton: UIButton!//学生名字按钮 - @IBOutlet var dateButton: UIButton!//日期按钮 - @IBOutlet var typeButton: UIButton!//筛选按钮 - override func awakeFromNib() { - super.awakeFromNib() - } - override func layoutSubviews() { - super.layoutSubviews() - nameButton.frame.origin = CGPoint(x: 15, y: 7) - dateButton.frame.origin = CGPoint(x: (getScreenWidth()-dateButton.frame.size.width)/2, y: 7) - typeButton.frame.origin = CGPoint(x: getScreenWidth()-typeButton.frame.size.width-30, y: 7) +class ReportHeaderView: UIView,UICollectionViewDelegate,UICollectionViewDataSource { + + lazy var collectionView = {()-> UICollectionView in + + let flowlayout = UICollectionViewFlowLayout() + flowlayout.itemSize = CGSize.init(width: screenWidth/7, height:60) + flowlayout.minimumLineSpacing = 0 + flowlayout.minimumInteritemSpacing = 0 + flowlayout.scrollDirection = UICollectionViewScrollDirection.horizontal + flowlayout.headerReferenceSize = CGSize.init(width: 0, height: 0) + flowlayout.footerReferenceSize = CGSize.init(width: 0, height: 0) + flowlayout.sectionInset = UIEdgeInsetsMake(0, 0, 0, 0) + + let collect = UICollectionView.init(frame: CGRect.init(x: 0, y: 0, width: self.bounds.size.width, height: self.bounds.size.height), collectionViewLayout: flowlayout) + collect.delegate = self + collect.dataSource = self + collect.showsHorizontalScrollIndicator = true + collect.scrollsToTop = false + collect.showsVerticalScrollIndicator = false + collect.isPagingEnabled = true + collect.backgroundColor = UIColor.white + collect.register(UINib.init(nibName: "ReportHeaderCollectionViewCell", bundle: nil), forCellWithReuseIdentifier: "ReportHeaderCollectionViewCell") + return collect + }() + + //Data + + /// 展示 + var count = Int() + /// 当月1号 周几 + var firstDay = Int() + /// 当月天数 + var monthDays = Int() + /// 今天日期 + var todayDate = Int() + + override init(frame: CGRect) { + super.init(frame: frame) + self.addSubview(self.collectionView) + + self.count = CalendarDateManager.shared.getMonthDayCount()*7 + self.firstDay = CalendarDateManager.shared.getFirstMonthDays() + self.monthDays = CalendarDateManager.shared.getCurrentMonthDay() + self.todayDate = CalendarDateManager.shared.getTodayDate() + + //初始位置:显示本周 + collectionView.scrollToItem(at: [0,count-1], at: UICollectionViewScrollPosition.right, animated: true) } - //点击学生姓名按钮 - @IBAction func changeStudentAction(_ sender: UIButton) { - delegate.selectStudentButton() + + //MARK: - Collection Delegate && DataSource + func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { + return count } - //点击日期按钮 - @IBAction func changeDateAction(_ sender: UIButton) { - delegate.selectDateButton() + func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { + + let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "ReportHeaderCollectionViewCell", for: indexPath) as! ReportHeaderCollectionViewCell + cell.setCellData(index: indexPath) + + // 超出这个月显示为空 + if indexPath.row+1 >= firstDay && indexPath.row <= monthDays { + cell.dataLab.text = "\(indexPath.row+1-firstDay+1)" + }else{ + cell.dataLab.text = "" + } + // 设置日期颜色 + if indexPath.row+1 > todayDate+firstDay-1{ + cell.dataLab.textColor = UIColor.gray + }else + if indexPath.row+1 == todayDate+firstDay-1 { + cell.dataLab.textColor = UIColor.red + }else{ + cell.dataLab.textColor = UIColor.black + } + return cell } - //点击筛选按钮 - @IBAction func changeTypeAction(_ sender: UIButton) { - delegate.selectTypeButton() + func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { + if indexPath.row >= firstDay-1 && indexPath.row < todayDate+firstDay-1 { + print("点击了 ...\(indexPath.row+1-firstDay+1)号") + } } + required init?(coder aDecoder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } } -protocol ReportHeaderViewDelegate { - func selectStudentButton() - func selectDateButton() - func selectTypeButton() -} -extension ReportHeaderView { - class func titleView() -> ReportHeaderView { - return Bundle.main.loadNibNamed("ReportHeaderView", owner: nil, options: nil)?.first as! ReportHeaderView +class CalendarDateManager: NSObject { + + static let shared = CalendarDateManager() + + private var date = Date.init(timeInterval: 150*86400, since: Date()) +// private var date = Date() + override init() {} + + /// 获取当前周ofMonth + /// + /// - Returns: 第几周 + func getMonthDayCount() -> Int { + let comps = Calendar.current.dateComponents([.weekOfMonth], from: date) + return comps.weekOfMonth! + } + + /// 获取当前月第一天周几 + /// + /// - Returns: 月1号周几 + func getFirstMonthDays() -> Int{ + let comps = Calendar.current.dateComponents([.day], from: date) + let dayDate = comps.day!-1 + let firstDay = Date.init(timeInterval: TimeInterval(-dayDate*86400), since: date) + let firstMonth = Calendar.current.dateComponents([.weekday], from: firstDay) + return firstMonth.weekday! + } + + /// 获取当天 + /// + /// - Returns: 今天几号 + func getTodayDate() -> Int { + let comps = Calendar.current.dateComponents([.day], from: date) + return comps.day! } + + /// 获取当月天数 + /// + /// - Returns: 天数 + func getCurrentMonthDay () ->Int{ + + let comps = Calendar.current.range(of: .day, in: .month, for: date) + return (comps?.count)! + } + } + + diff --git a/ParentAssistant/Pods/Pods.xcodeproj/xcuserdata/caoyang.xcuserdatad/xcschemes/xcschememanagement.plist b/ParentAssistant/Pods/Pods.xcodeproj/xcuserdata/caoyang.xcuserdatad/xcschemes/xcschememanagement.plist index 89dc66c..1e7f9aa 100644 --- a/ParentAssistant/Pods/Pods.xcodeproj/xcuserdata/caoyang.xcuserdatad/xcschemes/xcschememanagement.plist +++ b/ParentAssistant/Pods/Pods.xcodeproj/xcuserdata/caoyang.xcuserdatad/xcschemes/xcschememanagement.plist @@ -12,42 +12,42 @@ DZNEmptyDataSet.xcscheme orderHint - 1 + 2 Pods-ParentAssistant.xcscheme orderHint - 2 + 3 Reachability.xcscheme orderHint - 3 + 4 SDWebImage.xcscheme orderHint - 4 + 5 SVProgressHUD.xcscheme orderHint - 5 + 6 SwiftHash.xcscheme orderHint - 6 + 7 Toast.xcscheme orderHint - 7 + 8 XRCarouselView.xcscheme orderHint - 8 + 9 -- libgit2 0.21.0