我们如何禁用未来的日期并在swift中的日期标签下方传递字幕以及如何使用网桥标题

问题描述 投票:0回答:1

我不知道如何在Swift文件中使用Objective-C。我知道如何创建桥头文件但不知道如何使用它。 https://github.com/WenchaoD/FSCalendar。我正在使用这个豆荚。我想从今天开始禁用未来日期,并在日历中将字符串传递给字幕标签。我想在Swift中实现它。我在github.com上看到了一个Swift示例但没有工作谢谢是提前!

我也试过这个Disable future dates selection in FScalendar swift

if(!isAllowedToLimitFutureDates) 
{
    _maximumDate = [self.formatter dateFromString:@"2099-12-31"];
}
else
{
    _maximumDate = maxValidFutureDateAsString; // say "2017-03-13"
}
ios objective-c arrays swift xcode8
1个回答
1
投票

FSCalendar中,您可以通过符合FSCalendarDataSource来设置要选择的最大日期,从而实现:

maximumDate(for calendar: FSCalendar) -> Date

它告诉日历视图允许突出显示的最大日期是什么。例如:

确保您符合代表:

// conform to FSCalendarDelegate
class ViewController: UIViewController, FSCalendarDataSource {

    override func viewDidLoad() {
        super.viewDidLoad()

        // assign the delegate
        calendar.dataSource = self
    }
}

然后添加到您的视图控制器:

func maximumDate(for calendar: FSCalendar) -> Date {
    return Date()
}

这意味着最大日期是今天。

输出:

enter image description here

正如您所看到的,您可以选择任何以前的日期,但不能超过今天,从明天开始的日期将变为灰色(变暗和不可选)。

© www.soinside.com 2019 - 2024. All rights reserved.