首页 > 解决方案 > 在日历视图 ios 上显示事件标签/字符串?

问题描述

我正在开发我的一个 iOS 应用程序,我需要在该应用程序中添加日期事件,我正在尝试实现如下图所示的 UI 结果。

我已经使用FSCalendar 、 JTAppleCalendar 等解决了大部分区域,但我满足了我正在寻找的大多数要求,除了在 date 添加事件标签/字符串

使用 FSCalendar 库添加了当前状态截图。我只能看到点(ImageView)FSCalendar不允许我在日期上添加标签/字符串。

这是我的目标。

在此处输入图像描述

谁能帮助我如何实现这一目标?

先感谢您。

标签: iosswiftnscalendarfscalendar

解决方案


// 检查 FSCalendarDataSource // 告诉代理指定的单元格即将显示在日历中。

func calendar(_ calendar: FSCalendar, willDisplay cell: FSCalendarCell, for date: Date, at monthPosition: FSCalendarMonthPosition) {

        let labelMy2 = UILabel(frame: CGRect(x: 10, y: 20, width: cell.bounds.width, height: 20))
        labelMy2.font = UIFont(name: "Henderson BCG Sans", size: 10)
        labelMy2.text = "abc"
        labelMy2.layer.cornerRadius = cell.bounds.width/2
        labelMy2.textColor = UIColor.init(hex: "#32C77F")
        cell.addSubview(labelMy2)

}

推荐阅读