ios - 如何使用 Swift 在 FsCalendar 中为特定日期 (08-10-2017) 设置 ImagesForDates

标签 ios swift fscalendar

我已经为这个方法设置了日期

private func calendar(_ calendar: FSCalendar, imageFor date: Date) -> UIImage? {

let day: Int! = self.gregorian.component(.day, from: date)
        return [1,2,3].contains(day) ? UIImage(named: "mens") : nil
 }

我想设置它 - 它不起作用请帮助我:)

func calendar(_ calendar: FSCalendar, imageFor date: Date) -> UIImage? {
    let day: Int! = self.gregorian.component(.day, from: date)
    return [08-10-2017, 08-11-2017].contains(day) ? UIImage(named: "mens") : nil
 }

最佳答案

let day: Int! = self.gregorian.component(.day, from: date)

这条线会在当天返回给您。例如:- 08-10-2017 它将返回 08。 因此,首先将 date func calendar(_ calendar: FSCalendar, imageFor date: Date) -> UIImage? 转换为您的 dd-MM-yyyy 格式。

然后使用此 return [08-10-2017, 08-11-2017].contains(date) ? UIImage(命名为:“男士”):无

希望这对您有所帮助!

关于ios - 如何使用 Swift 在 FsCalendar 中为特定日期 (08-10-2017) 设置 ImagesForDates,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45633769/

相关文章:

iphone - 将 View 添加到可变数组中

ios - 子类 UIView 上的 UIPanGestureRecognizer

ios - 在项目中全局更改 FSCalendar 的时区

iphone - 即时更改 UINavigationController 样式-objective-c

ios - 当使用 modalPresentationStyle = .FormSheet 在 UINavigationController 中推送时,SFSafariViewController 显示不正确

ios - tableView 中多个 NSTimer 对象的问题

ios - 如何从静态字符串中获取日期?

ios - 创建像 iOS 日历一样的 TableView

ios - 为什么我的 UI 会在我明确离开返回主线程时更新

ios - 添加滑动删除 UITableViewCell