How to disable title placeholder (Previous/next month dates )in FSCalendar - ios

I'm using FScalendar for previous & next month calendar. How to remove the previous/next month dates from the current calendar?

You can only HIDE the Next & Previous month dates.
override func viewDidLoad() {
fsCalendarObject.placeholderType = .none


Unlock Content based on Day (iOS App with Xcode)

I am trying to get create an app where you can unlock a certain picture every day throughout the month of December, like an advent calendar.
So if the user is pressing the button for a certain day (all days have a button with their date on) the app shall compare the current date on the device to the unlock date. For example:
If the user is pressing the button for the 01.12.18 (dd.MM.yy) and it currently ist that day or any day later it shall display picture number one.
Else: (if the day isn't reached yet) the user shall see another picture, that says sth. like "You're too early! Please wait some more."
Any suggestions or example codes are very appreciated!
The prototype of the code looks like this:
import UIKit
class ViewController: UIViewController {
override func viewDidLoad() {
#IBOutlet weak var dailyContent: UIImageView!
#IBAction func türchen1Button(_ sender: Any) {
// if 01.12.18 (dd.MM.yy) is today or past today
// dailyContent.image = picture1
// else if 01.12.18 (dd.MM.yy) is in the future
// dailyContent.image = pictureTooEarly
This app shall be a present for my girlfriend and I appreciate every help!
Thank you in advance!
Assign the tags 1 - 24 to the buttons which represent the days.
Use one IBAction and connect all buttons to this action.
#IBAction func türchenButton(_ sender: UIButton) {
In the body of the action get the current year and create a date of the corresponding button and check if the date is in the future
let now = Date()
let calendar = Calendar.current
let currentYear = calendar.component(.year, from: now)
let türchenComponents = DateComponents(year: currentYear, month: 12, day: sender.tag)
let türchenDay = türchenComponents)!
ifürchenDay, to: now, toGranularity: .day) == .orderedDescending {
// is in the future
dailyContent.image = pictureTooEarly
} else {
// is today or past today
dailyContent.image = picture1

How to add an existing date to a UIDatePicker

I want to add the abbility, to edit an existing action with an attribute date which comes from a datePicker. Than I have to assign the date to a datePicker.
How can I assign this date to a datePicker?
Just set the date property
let picker = UIDatePicker()
let date = Date() // current date = date
If you want animation you can do:
let picker = UIDatePicker()
let date = Date()
picker.setDate(date, animated: true)
A good way to solve such problem is to read documentation of UIDatePicker

Add custom holidays in FSCalendar

I am using FSCalendar and its displaying only default holidays like on Sunday (The weekend) and so I want to add my own holidays in it and change color.
So please anyone knows how to add custom holidays????
I think you have to maintain holidays list on code level like model class(Array) or you can use the database for storing holidays list. At the render time only adopt the FSCalendarDelegateAppearance delegate. This call a delegate function for every date.
See example i think it can help you,
var datesWithHolidays = ["2018/09/03", "2018/10/06", "2018/09/12", "2018/10/25"]
//This is the delegate method
func calendar(_ calendar: FSCalendar, appearance: FSCalendarAppearance, fillDefaultColorFor date: Date) -> UIColor? {
let dateString = self.dateFormatter1.string(from: date)
if self.datesWithHolidays.contains(dateString) {
return nil

How to advance other fields in datePicker automatically?

Let's say that I have a UIDatePicker and the mode is set to .date.
I want the following behaviour:
For example, March has 30 days. If I scroll below the 30th day, I want the month to be automatically incremented to April and so on.
Is there a property that does just that? I couldn't find one.
I don't think there's any way to do what you want with a normal UIDatePicker. You could attach an action to the valueChanged event, but that doesn't get called until the date picker stops moving.
You could probably create a custom date picker using a standard UIPickerView. You could use the data source methods to figure out when the "wheels" are turned, call selectedRow(inComponent:) to figure out which values are selected for each wheel, and then call selectRow(_:inComponent:animated) to switch the month if the user scrolls the day past the end of the month.
How to advance other fields in datePicker automatically?
The best way to do this is using the Target-Action design pattern. Basically, when a user chooses a new date (action), the view (a target) does something.
Here's some code that changes the day value to 1 if it's set to 0:
override func viewDidLoad() {
let datePicker = UIDatePicker()
datePicker.datePickerMode = .date
datePicker.addTarget(self, action: #selector(doStuff(sender:)), for: UIControlEvents.valueChanged)
#IBAction func doStuff(sender: UIDatePicker) {
let calendar = Calendar.current
let components = calendar.dateComponents([.day], from:
if == 0 {
// Using Calendar.current automatically takes care of Time Zones for us.
if let date = .day, value: 1, to: {
sender.setDate(date, animated: true)
Note: This example is in Swift 4.
No, there is no property that does this that I am aware of.

Running a piece of code after a certain interval, Swift

I am trying to figure out how to reset a label in an app after every 7 days even though the user launches the app on the 8th day.
To simplify the approach I have a label with a string set to it in ViewDidLoad.
override func viewDidLoad() {
self.nameLabel.text = "Today"
// Check for the current day
let date = Date()
let formatter = DateFormatter()
formatter.dateFormat = "EEEE"
let WeekDay = formatter.string(from: date)
I can check for which day it is but is there a way to ensure I save the day and then check if the day has passed Sunday to then change the label to something else?
Thanks in advance.