1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

FSCalendarの日付の下にLabelを表示させる

Posted at

FSCalendar関連で調べていたのですがイベントのドットを表示する方法が多く、Labelを表示する方法が少なかったのでここに残しておきます。

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

        let taijulabel = UILabel(frame: CGRect(x: 20, y: 25, width: 20, height: 20))
        taijulabel.font = UIFont.systemFont(ofSize: 8)
        taijulabel.text = "23"
        taijulabel.textColor = UIColor.lightGray
        taijulabel.layer.cornerRadius = cell.bounds.width/2

        cell.addSubview(taijulabel)

    }

willDisplay cellメソッドを使用します。

cell.addSubviewでCellの上にラベルを貼るイメージでしょうか。

今回は日付の下に小さく数字を入れてみました。
スクリーンショット 2021-05-15 9.25.53.png

こんな感じになります。

色々できそうなので、幅が広がりそうです!

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?