Search code examples
iosswiftnscalendarfscalendar

Show event label/string on calendar view ios?


I am working on one of my iOS application where I am needed to add the events on the date, I am trying to achieve the UI result like in bellow screenshot.

I've worked out most of area using FSCalendar, JTAppleCalendar etc but I meet most of requirements which I am looking for except the adding event label/string on date.

Added current status screenshot using FSCalendar Library. I can see only dots(ImageView) FSCalendar is not allowing me to add the label/string on date.

Here is What I'm aiming to do.

enter image description here

Can anyone help me how can achieve this?

Thank you in advance.


Solution

  • // check FSCalendarDataSource // Tells the delegate that the specified cell is about to be displayed in the calendar.

    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)
    
    }