3
4

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で指定の日付をコードで選択する方法

Posted at

概要

・FSCalendarで画面遷移した際などに、指定の日付に選択させる。
・画面遷移先での日付の指定に困ったので、Qiitaに書きます。

コード

ViewController.swift

@IBOutlet weak var calView: FSCalendar!


override func viewWillAppear(_ animated: Bool) {
            
    let calPosition = Calendar.current
    //ここの日付の指定はInt型
    let selectDay = calPosition.date(from: DateComponents(year: 2020, month: 11, day: 5))
    calView.select(selectDay)
}

補足

・DateComponentsでの日付指定はInt型
・自分は別画面で取得した値がStringなのでIntにキャストしています。
・見やすいようにInt型で書いています。

3
4
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
3
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?