FSCalendar-Xamarin-iOS icon indicating copy to clipboard operation
FSCalendar-Xamarin-iOS copied to clipboard

How to use FSCalendarDelegateAppearance?

Open mohibsheth opened this issue 7 years ago • 2 comments

Hi @MarcBruins ,

First of all, thank you very much for the binding. The control is awesome and it's very helpful to see a working binding for it.

We have started using this library in our app but we aren't able to figure out how to use the FSCalendarDelegateAppearance?

I can see the definition for it but don't see any way to provide it's implementation to the FSCalendar instance.

Do you know how?

Thanks

mohibsheth avatar Jul 28 '17 11:07 mohibsheth

I was stuck on the same problem, solved it by following. You can achieve the same by setting calendar’s weakdelegate to this(the view controller). And then get the methods you want to override without the override keyword. You will need the export keyword along with native method name on top of that though. Also, this was done in Xamarin C#, not sure if that’s what you are looking for.

Also, the weakdelegate calls methods for both fscalenderappearancedelegate and fscalenderdelegate.

Best Regards, Abhimanyu Singhal

Sent from my iPhone

On Jul 28, 2017, at 4:36 PM, mohibsheth [email protected] wrote:

Hi @MarcBruins ,

First of all, thank you very much for the binding. The control is awesome and it's very helpful to see a working binding for it.

We have started using this library in our app but we aren't able to figure out how to use the FSCalendarDelegateAppearance?

I can see the definition for it but don't see any way to provide it's implementation to the FSCalendar instance.

Do you know how?

Thanks

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

singhal2 avatar Jul 28 '17 13:07 singhal2

Thanks singhal2.

Here's how I did it

public partial class ViewController : UIViewController
    {
   
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            calendar.WeakDelegate = this;
        }

        [Export("calendar:appearance:titleDefaultColorForDate:")]
        public UIColor TitleDefaultColorForDate(FSCalendar calendar, FSCalendarAppearance appearance, NSDate date)
        {
            DateTime dt1 = new DateTime(2018, 1, 6);
            DateTime dt2 = date.ToDateTime();

            if (dt1.Date == dt2.Date)
            {
                return UIColor.Black;
            }
            return UIColor.Gray;
        }
}

drunkendaddy avatar Jan 16 '18 09:01 drunkendaddy