### Install RVCalendarWeekView via CocoaPods Source: https://context7.com/badchoice/rvcalendarweekview/llms.txt Add the library dependency to your project's Podfile. ```ruby # Podfile pod 'RVCalendarWeekView' ``` -------------------------------- ### Create Calendar Events with MSEvent Source: https://context7.com/badchoice/rvcalendarweekview/llms.txt Instantiate calendar events using various factory methods for start times, durations, or explicit end times. ```objective-c #import "MSEvent.h" #import "NSDate+Easy.h" // Create event starting now with default 1-hour duration MSEvent *event1 = [MSEvent make:NSDate.now title:@"Team Meeting" subtitle:@"Conference Room A"]; // Create event with specific duration (in minutes) MSEvent *event2 = [MSEvent make:[NSDate.now addMinutes:30] duration:60 * 2 // 2 hours title:@"Project Review" subtitle:@"Main Office"]; // Create event with explicit start and end times NSDate *startTime = [NSDate.tomorrow addHours:9]; NSDate *endTime = [NSDate.tomorrow addHours:11]; MSEvent *event3 = [MSEvent make:startTime end:endTime title:@"Client Call" subtitle:@"Phone"]; // Check if event falls on a specific day BOOL isToday = [event1 isInDay:NSDate.now]; NSDate *eventDay = [event1 day]; ``` -------------------------------- ### Configure MSWeekView Component Source: https://context7.com/badchoice/rvcalendarweekview/llms.txt Set up the week view layout and delegate methods within a view controller. ```objective-c #import "MSWeekView.h" #import "MSEvent.h" @interface MyViewController () @property (weak, nonatomic) IBOutlet MSWeekView *weekView; @end @implementation MyViewController - (void)viewDidLoad { [super viewDidLoad]; // Configure display options _weekView.delegate = self; _weekView.daysToShowOnScreen = 7; // Days visible at once _weekView.daysToShow = 31; // Total days to load _weekView.weekFlowLayout.show24Hours = YES; // Show all 24 hours _weekView.weekFlowLayout.hourHeight = 50; // Pixel height per hour _weekView.weekFlowLayout.hourGridDivisionValue = MSHourGridDivision_15_Minutes; // Create and set events MSEvent *event1 = [MSEvent make:NSDate.now title:@"Meeting" subtitle:@"Room 101"]; MSEvent *event2 = [MSEvent make:[NSDate.now addHours:3] duration:90 title:@"Lunch" subtitle:@"Cafeteria"]; _weekView.events = @[event1, event2]; } // Required delegate method - handle event selection - (void)weekView:(id)sender eventSelected:(MSEventCell *)eventCell { NSLog(@"Selected event: %@", eventCell.event.title); // Present event details, edit dialog, etc. } // Optional delegate method - define unavailable time periods - (NSArray *)weekView:(id)sender unavailableHoursPeriods:(NSDate *)date { return @[ [MSHourPerdiod make:@"00:00" end:@"08:00"], // Before work hours [MSHourPerdiod make:@"18:00" end:@"24:00"] // After work hours ]; } @end ``` -------------------------------- ### Complete CalendarViewController Implementation Source: https://context7.com/badchoice/rvcalendarweekview/llms.txt A full implementation of a view controller integrating multiple delegate protocols and the decorator factory to enable calendar features. ```Objective-C // CalendarViewController.h #import #import "MSWeekViewDecoratorFactory.h" @interface CalendarViewController : UIViewController < MSWeekViewDelegate, MSWeekViewDragableDelegate, MSWeekViewNewEventDelegate, MSWeekViewInfiniteDelegate, MSWeekViewChangeDurationDelegate> @property (weak, nonatomic) IBOutlet MSWeekView *weekView; @property (strong, nonatomic) MSWeekView *decoratedWeekView; @end // CalendarViewController.m #import "CalendarViewController.h" @implementation CalendarViewController { NSArray *_unavailableHours; } - (void)viewDidLoad { [super viewDidLoad]; [self setupCalendar]; } - (void)setupCalendar { // Configure all features self.decoratedWeekView = [MSWeekViewDecoratorFactory make:self.weekView features:(MSChangeDurationAndDragableFeature | MSNewEventFeature | MSInfiniteFeature | MSPinchableFeature | MSShortPressNewEventFeature) andDelegate:self]; [MSWeekViewDecoratorFactory setMinutesPrecisionToAllDecorators:self.decoratedWeekView minutesPrecision:15]; // Configure display _weekView.delegate = self; _weekView.weekFlowLayout.show24Hours = YES; _weekView.weekFlowLayout.hourGridDivisionValue = MSHourGridDivision_15_Minutes; _weekView.weekFlowLayout.hourHeight = 50; // Device-specific layout if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { _weekView.daysToShowOnScreen = 7; } else { _weekView.daysToShowOnScreen = 2; } _weekView.daysToShow = 30; // Load initial events _weekView.events = [self loadInitialEvents]; } - (NSArray *)loadInitialEvents { return @[ [MSEvent make:NSDate.now title:@"Team Sync" subtitle:@"Conference Room"], [MSEvent make:[NSDate.now addHours:2] duration:90 title:@"Project Review" subtitle:@"Main Office"] ]; } #pragma mark - MSWeekViewDelegate - (void)weekView:(id)sender eventSelected:(MSEventCell *)eventCell { NSLog(@"Selected: %@", eventCell.event.title); } - (NSArray *)weekView:(id)sender unavailableHoursPeriods:(NSDate *)date { if (!_unavailableHours) { _unavailableHours = @[ [MSHourPerdiod make:@"00:00" end:@"09:00"], [MSHourPerdiod make:@"18:00" end:@"24:00"] ]; } return _unavailableHours; } #pragma mark - Drag Delegate - (BOOL)weekView:(MSWeekView *)weekView canStartMovingEvent:(MSEvent *)event { return YES; } - (BOOL)weekView:(MSWeekView *)weekView canMoveEvent:(MSEvent *)event to:(NSDate *)date { return [date compare:NSDate.now] != NSOrderedAscending; } - (void)weekView:(MSWeekView *)weekView event:(MSEvent *)event moved:(NSDate *)date { NSLog(@"Moved to: %@", date); } #pragma mark - New Event Delegate - (void)weekView:(MSWeekView *)weekView onLongPressAt:(NSDate *)date { MSEvent *event = [MSEvent make:date title:@"New Event" subtitle:@"Location"]; [_weekView addEvent:event]; } - (void)weekView:(MSWeekView *)weekView onTapAt:(NSDate *)date { NSLog(@"Tapped: %@", date); } #pragma mark - Infinite Delegate - (BOOL)weekView:(MSWeekView *)weekView newDaysLoaded:(NSDate *)startDate to:(NSDate *)endDate { NSLog(@"Loading: %@ - %@", startDate, endDate); return YES; } #pragma mark - Duration Delegate - (BOOL)weekView:(MSWeekView *)weekView canChangeDuration:(MSEvent *)event startDate:(NSDate *)startDate endDate:(NSDate *)endDate { return YES; } - (void)weekView:(MSWeekView *)weekView event:(MSEvent *)event durationChanged:(NSDate *)startDate endDate:(NSDate *)endDate { NSLog(@"Duration changed"); } @end ``` -------------------------------- ### Fix Masonry Pod Preprocessor Definition Error Source: https://github.com/badchoice/rvcalendarweekview/blob/master/README.md Add this post-install hook to your Podfile to resolve build issues related to Masonry shorthand definitions. ```ruby #To fix the masonry preprocessor definition post_install do |installer| installer.pods_project.targets.each do |target| target.build_configurations.each do |config| config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= ['$(inherited)'] config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] << 'MAS_SHORTHAND=1' end end end ``` -------------------------------- ### Implement Infinite Scroll Delegate Source: https://github.com/badchoice/rvcalendarweekview/blob/master/README.md Delegate method for loading new days during infinite scroll. ```objective-c -(BOOL)weekView:(MSWeekView*)weekView newDaysLoaded:(NSDate*)startDate to:(NSDate*)endDate; ``` -------------------------------- ### Apply Features via Decorator Factory Source: https://github.com/badchoice/rvcalendarweekview/blob/master/README.md Use the factory to quickly add multiple features to the week view. Requires a strong reference to the returned decorator. ```objective-c self.decoratedWeekView = [MSWeekViewDecoratorFactory make:self.weekView features:(MSDragableEventFeature|MSNewEventFeature|MSInfiniteFeature|MSChangeDurationFeature) andDelegate:self]; ``` -------------------------------- ### Implement Drag and Drop Delegates Source: https://github.com/badchoice/rvcalendarweekview/blob/master/README.md Delegate methods for handling event movement. ```objective-c -(BOOL)weekView:(MSWeekView*)weekView canMoveEvent:(MSEvent*)event to:(NSDate*)date; -(void)weekView:(MSWeekView*)weekView event:(MSEvent*)event moved:(NSDate*)date; ``` -------------------------------- ### Initialize Events in View Controller Source: https://github.com/badchoice/rvcalendarweekview/blob/master/README.md Create and assign events to the week view within the viewDidLoad method. ```objective-c -(void)viewDidLoad{ MSEvent* event1 = [MSEvent make:NSDate.now title:@"Title" location:@"Central perk"]; MSEvent* event2 = [MSEvent make:[NSDate.now addMinutes:10] //AddMinutes comes from EasyDate pod duration:60*3 title:@"Title 2" location:@"Central perk"]; _weekView.events = @[event1,event2]; } ``` -------------------------------- ### Enable Event Creation on Tap/Long Press Source: https://context7.com/badchoice/rvcalendarweekview/llms.txt Implement event creation using MSWeekViewDecoratorNewEvent. Use MSShortPressNewEventFeature for tap gestures and MSNewEventFeature for long press. The delegate methods `weekView:onLongPressAt:` and `weekView:onTapAt:` handle the creation logic. ```objc @interface MyViewController () @end @implementation MyViewController - (void)setupNewEventCreation { // Enable both long press and short press for new events self.decoratedWeekView = [MSWeekViewDecoratorFactory make:self.weekView features:(MSNewEventFeature | MSShortPressNewEventFeature) andDelegate:self]; } #pragma mark - MSWeekViewNewEventDelegate // Handle long press - create event at pressed location - (void)weekView:(MSWeekView *)weekView onLongPressAt:(NSDate *)date { NSLog(@"Long press at: %@", date); // Create new event at pressed time MSEvent *newEvent = [MSEvent make:date duration:60 // 1 hour default title:@"New Event" subtitle:@"Tap to edit"]; [weekView addEvent:newEvent]; // Optionally show edit dialog [self showEventEditor:newEvent]; } // Handle short tap - show time picker or quick-add dialog - (void)weekView:(MSWeekView *)weekView onTapAt:(NSDate *)date { NSLog(@"Tapped at: %@", date); // Show quick-add alert UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"Create Event" message:[NSString stringWithFormat:@"Add event at %@?", date] preferredStyle:UIAlertControllerStyleAlert]; [alert addAction:[UIAlertAction actionWithTitle:@"Create" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) { MSEvent *event = [MSEvent make:date title:@"Quick Event" subtitle:@""]; [weekView addEvent:event]; }]]; [alert addAction:[UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:nil]]; [self presentViewController:alert animated:YES completion:nil]; } @end ``` -------------------------------- ### Implement Change Duration Delegates Source: https://github.com/badchoice/rvcalendarweekview/blob/master/README.md Delegate methods for handling event duration changes. ```objective-c -(BOOL)weekView:(MSWeekView*)weekView canChangeDuration:(MSEvent*)event startDate:(NSDate*)startDate endDate:(NSDate*)endDate; -(void)weekView:(MSWeekView*)weekView event:(MSEvent*)event durationChanged:(NSDate*)startDate endDate:(NSDate*)endDate; ``` -------------------------------- ### Implement Drag and Drop with MSWeekViewDecoratorDragable Source: https://context7.com/badchoice/rvcalendarweekview/llms.txt Enable event dragging by implementing the MSWeekViewDragableDelegate protocol. Features can be added via the factory or initialized manually. ```objective-c @interface MyViewController () @end @implementation MyViewController // Setup with drag feature - (void)setupDragableWeekView { self.decoratedWeekView = [MSWeekViewDecoratorFactory make:self.weekView features:MSDragableEventFeature andDelegate:self]; } // Alternative: Manual decorator setup for more control - (void)setupDragableManually { self.decoratedWeekView = [MSWeekViewDecoratorDragable makeWith:self.weekView andDelegate:self]; } #pragma mark - MSWeekViewDragableDelegate // Optional: Control whether an event can start being dragged - (BOOL)weekView:(MSWeekView *)weekView canStartMovingEvent:(MSEvent *)event { // Prevent dragging locked events return ![event.title containsString:@"[Locked]"]; } // Required: Validate if event can be moved to target date/time - (BOOL)weekView:(MSWeekView *)weekView canMoveEvent:(MSEvent *)event to:(NSDate *)date { // Example: Prevent moving events to past dates if ([date compare:NSDate.now] == NSOrderedAscending) { return NO; } // Example: Prevent moving to weekends NSCalendar *calendar = [NSCalendar currentCalendar]; NSInteger weekday = [calendar component:NSCalendarUnitWeekday fromDate:date]; if (weekday == 1 || weekday == 7) { return NO; } return YES; } // Required: Handle completed move operation - (void)weekView:(MSWeekView *)weekView event:(MSEvent *)event moved:(NSDate *)date { NSLog(@"Event '%@' moved to %@", event.title, date); // Persist change to database, sync with server, etc. } @end ``` -------------------------------- ### Apply Features Manually Source: https://github.com/badchoice/rvcalendarweekview/blob/master/README.md Manually chain decorators for more flexibility in feature configuration. ```objective-c MSWeekView* decoratedView = baseView; decoratedView = [MSWeekViewDecoratorInfinite makeWith:decoratedView andDelegate:infiniteDelegate]; decoratedView = [MSWeekViewDecoratorNewEvent makeWith:decoratedView andDelegate:newEventDelegate]; decoratedView = [MSWeekViewDecoratorDragable makeWith:decoratedView andDelegate:dragableDelegate]; decoratedView = [MSWeekViewDecoratorChangeDuration makeWith:decoratedView andDelegate:durationDelegate]; ``` -------------------------------- ### Implement Long Press Delegate Source: https://github.com/badchoice/rvcalendarweekview/blob/master/README.md Delegate method for handling new event creation via long press. ```objective-c -(void)weekView:(MSWeekView*)weekView onLongPressAt:(NSDate*)date ``` -------------------------------- ### Enable Infinite Scrolling for Event Loading Source: https://context7.com/badchoice/rvcalendarweekview/llms.txt Implement infinite scrolling with MSWeekViewDecoratorInfinite to load additional days as the user scrolls. The `weekView:newDaysLoaded:to:` delegate method is called when a new date range becomes visible, allowing for lazy loading of events. Return YES if events were added to trigger a refresh, otherwise return NO for performance. ```objc @interface MyViewController () @end @implementation MyViewController - (void)setupInfiniteScrolling { self.decoratedWeekView = [MSWeekViewDecoratorFactory make:self.weekView features:MSInfiniteFeature andDelegate:self]; } #pragma mark - MSWeekViewInfiniteDelegate // Called when user scrolls to new date range - (BOOL)weekView:(MSWeekView *)weekView newDaysLoaded:(NSDate *)startDate to:(NSDate *)endDate { NSLog(@"Loading events from %@ to %@", startDate, endDate); // Fetch events from server/database for date range [self fetchEventsFromServer:startDate to:endDate completion:^(NSArray *events) { if (events.count > 0) { [weekView addEvents:events]; } }]; // Return YES if events were added to trigger refresh // Return NO if no new events to improve performance return YES; } // Example: Simulated event loading - (void)fetchEventsFromServer:(NSDate *)start to:(NSDate *)end completion:(void(^)(NSArray *))completion { // Simulate async fetch dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ NSMutableArray *events = [NSMutableArray array]; // Add sample events for each day in range NSDate *currentDate = start; while ([currentDate compare:end] == NSOrderedAscending) { MSEvent *event = [MSEvent make:[currentDate addHours:10] duration:60 title:@"Daily Standup" subtitle:@"Team Room"]; [events addObject:event]; currentDate = [currentDate addDays:1]; } dispatch_async(dispatch_get_main_queue(), ^{ completion(events); }); }); } @end ``` -------------------------------- ### Compose Features with MSWeekViewDecoratorFactory Source: https://context7.com/badchoice/rvcalendarweekview/llms.txt Use bitwise OR to combine multiple features and ensure a strong reference is held to the decorated view. ```objective-c #import "MSWeekViewDecoratorFactory.h" @interface MyViewController () @property (weak, nonatomic) IBOutlet MSWeekView *weekView; @property (strong, nonatomic) MSWeekView *decoratedWeekView; // Must be strong! @end @implementation MyViewController - (void)viewDidLoad { [super viewDidLoad]; // Add multiple features using bitwise OR self.decoratedWeekView = [MSWeekViewDecoratorFactory make:self.weekView features:(MSDragableEventFeature | MSNewEventFeature | MSInfiniteFeature | MSChangeDurationFeature | MSPinchableFeature) andDelegate:self]; // Optional: Set minutes precision for all decorators (default is 5) [MSWeekViewDecoratorFactory setMinutesPrecisionToAllDecorators:self.decoratedWeekView minutesPrecision:15]; } @end ``` -------------------------------- ### Manage Events in MSWeekView Source: https://context7.com/badchoice/rvcalendarweekview/llms.txt Perform dynamic updates to the calendar by adding, removing, or reloading events. ```objective-c // Add a single event MSEvent *newEvent = [MSEvent make:NSDate.now title:@"Quick Meeting" subtitle:@"Lobby"]; [_weekView addEvent:newEvent]; // Add multiple events at once NSArray *newEvents = @[ [MSEvent make:[NSDate.now addHours:1] title:@"Call" subtitle:@"Phone"], [MSEvent make:[NSDate.now addHours:2] title:@"Review" subtitle:@"Office"] ]; [_weekView addEvents:newEvents]; // Remove a specific event [_weekView removeEvent:newEvent]; // Force reload the calendar view [_weekView forceReload:YES]; // YES to reload events, NO for layout only // Get the first visible day NSDate *firstVisibleDay = [_weekView firstDay]; ``` -------------------------------- ### Resize Events with MSWeekViewDecoratorChangeDuration Source: https://context7.com/badchoice/rvcalendarweekview/llms.txt Manage event duration changes by implementing MSWeekViewChangeDurationDelegate. You can use combined features or duration-only features. ```objective-c @interface MyViewController () @end @implementation MyViewController - (void)setupChangeDuration { // Use combined drag + duration change feature self.decoratedWeekView = [MSWeekViewDecoratorFactory make:self.weekView features:MSChangeDurationAndDragableFeature andDelegate:self]; // Or use duration change only self.decoratedWeekView = [MSWeekViewDecoratorFactory make:self.weekView features:MSChangeDurationFeature andDelegate:self]; } #pragma mark - MSWeekViewChangeDurationDelegate // Validate duration change - (BOOL)weekView:(MSWeekView *)weekView canChangeDuration:(MSEvent *)event startDate:(NSDate *)startDate endDate:(NSDate *)endDate { // Minimum 30 minutes duration NSTimeInterval duration = [endDate timeIntervalSinceDate:startDate]; if (duration < 30 * 60) { return NO; } // Maximum 8 hours duration if (duration > 8 * 60 * 60) { return NO; } return YES; } // Handle duration change completion - (void)weekView:(MSWeekView *)weekView event:(MSEvent *)event durationChanged:(NSDate *)startDate endDate:(NSDate *)endDate { NSLog(@"Event '%@' duration changed: %@ - %@", event.title, startDate, endDate); // Update event times event.StartDate = startDate; event.EndDate = endDate; // Persist changes } @end ``` -------------------------------- ### Configure RVCalendarWeekView Layout Options Source: https://github.com/badchoice/rvcalendarweekview/blob/master/README.md Modify these properties to adjust the visual layout, hour grid divisions, and the number of visible days in the calendar view. ```objective-c _weekView.weekFlowLayout.show24Hours = YES; //Show All hours or just the min to cover all events _weekView.weekFlowLayout.hourHeight = 50; //Define the hour height _weekView.daysToShowOnScreen = 7; //How many days visible at the same time _weekView.daysToShow = 31; //How many days to display (Ininite scroll feature pending) _weekView.weekFlowLayout.hourGridDivisionValue = MSHourGridDivision_15_Minutes; // Show hour division lines (at lower alpha) each X minutes, by default its NONE so they are not shown. ``` -------------------------------- ### Set Minutes Precision Source: https://github.com/badchoice/rvcalendarweekview/blob/master/README.md Configure the time precision for all decorators attached to the view. ```objective-c [MSWeekViewDecoratorFactory setMinutesPrecisionToAllDecorators:decoratedView minutesPrecision:15]; ``` -------------------------------- ### Configure MSCollectionViewCalendarLayout Source: https://context7.com/badchoice/rvcalendarweekview/llms.txt Adjust the visual presentation of the calendar grid by configuring properties of MSCollectionViewCalendarLayout. This includes hour height, section width, gridlines, and header positioning. Use scroll methods to navigate to specific times. ```objc // Access through weekView.weekFlowLayout MSCollectionViewCalendarLayout *layout = _weekView.weekFlowLayout; // Display options layout.show24Hours = YES; // Show full 24 hours vs event range layout.hourHeight = 60; // Pixels per hour layout.sectionWidth = 100; // Width per day column layout.dayColumnHeaderHeight = 40; // Header height layout.timeRowHeaderWidth = 50; // Time column width // Grid division lines layout.hourGridDivisionValue = MSHourGridDivision_15_Minutes; // Options: MSHourGridDivision_NONE, _05_Minutes, _10_Minutes, // _15_Minutes, _20_Minutes, _30_Minutes // Gridline dimensions layout.horizontalGridlineHeight = 1.0; layout.verticalGridlineWidth = 1.0; layout.currentTimeHorizontalGridlineHeight = 2.0; // Margins layout.sectionMargin = UIEdgeInsetsMake(0, 0, 0, 0); layout.contentMargin = UIEdgeInsetsMake(0, 0, 0, 0); layout.cellMargin = UIEdgeInsetsMake(1, 1, 1, 1); // Layout type layout.sectionLayoutType = MSSectionLayoutTypeHorizontalTile; layout.headerLayoutType = MSHeaderLayoutTypeTimeRowAboveDayColumn; // Scroll to specific times [layout scrollCollectionViewToCurrentTime:YES]; // Animated scroll to now [layout scrollCollectionViewToClosetSectionToCurrentTimeAnimated:YES]; // Scroll to specific time NSDate *targetTime = [NSDate.now addHours:2]; [layout scrollCollectionViewToClosetSectionToTime:targetTime animated:YES]; // Invalidate cache when data changes [layout invalidateLayoutCache]; ``` -------------------------------- ### Display Unavailable Hours Source: https://github.com/badchoice/rvcalendarweekview/blob/master/README.md Optional delegate method to define and return periods of unavailable hours. ```objective-c //This one is optional -(NSArray*)weekView:(id)sender unavailableHoursPeriods:(NSDate*)date{ if(!unavailableHours){ unavailableHours = @[ [MSHourPerdiod make:@"00:00" end:@"09:00"], [MSHourPerdiod make:@"18:30" end:@"21:00"], ]; } return unavailableHours; } ``` -------------------------------- ### Define Unavailable Hours with MSHourPeriod Source: https://context7.com/badchoice/rvcalendarweekview/llms.txt Use MSHourPeriod to specify time ranges for unavailable hours. Implement the weekView:unavailableHoursPeriods: delegate method to return these periods for specific dates, allowing for different schedules on weekdays and weekends. ```objc #import "MSHourPerdiod.h" // Create unavailable hour periods with time strings (HH:MM format) MSHourPerdiod *earlyMorning = [MSHourPerdiod make:@"00:00" end:@"08:00"]; MSHourPerdiod *lunchBreak = [MSHourPerdiod make:@"12:00" end:@"13:00"]; MSHourPerdiod *evening = [MSHourPerdiod make:@"18:00" end:@"24:00"]; // Access period properties int startHour = [earlyMorning startHour]; // 0 int startMinute = [earlyMorning startMinute]; // 0 float duration = [earlyMorning duration]; // 8.0 (hours) float startWithPct = [earlyMorning startTimeWithMinutesPercentage]; ``` ```objc // Implement delegate to return unavailable periods per day - (NSArray *)weekView:(id)sender unavailableHoursPeriods:(NSDate *)date { NSCalendar *calendar = [NSCalendar currentCalendar]; NSInteger weekday = [calendar component:NSCalendarUnitWeekday fromDate:date]; // Different schedules for weekdays vs weekends if (weekday == 1 || weekday == 7) { // Weekend - all day unavailable return @[[MSHourPerdiod make:@"00:00" end:@"24:00"]]; } else { // Weekday - business hours only return @[ [MSHourPerdiod make:@"00:00" end:@"09:00"], [MSHourPerdiod make:@"17:00" end:@"24:00"] ]; } } ``` -------------------------------- ### Create Custom Event Cell Appearance Source: https://context7.com/badchoice/rvcalendarweekview/llms.txt Subclass MSEventCell to customize the appearance of event cells, including background color, text color, and text attributes. Register your custom cell class in your MSWeekView subclass. ```objc // CustomEventCell.h #import "MSEventCell.h" @interface CustomEventCell : MSEventCell @end // CustomEventCell.m @implementation CustomEventCell - (UIColor *)backgroundColorHighlighted:(BOOL)selected { if (selected) { return [UIColor colorWithRed:0.2 green:0.6 blue:0.9 alpha:1.0]; } return [UIColor colorWithRed:0.3 green:0.7 blue:1.0 alpha:0.9]; } - (UIColor *)textColorHighlighted:(BOOL)selected { return [UIColor whiteColor]; } - (UIColor *)borderColor { return [UIColor colorWithRed:0.1 green:0.4 blue:0.7 alpha:1.0]; } - (NSDictionary *)titleAttributesHighlighted:(BOOL)highlighted { return @{ NSFontAttributeName: [UIFont boldSystemFontOfSize:12], NSForegroundColorAttributeName: [self textColorHighlighted:highlighted] }; } - (NSDictionary *)subtitleAttributesHighlighted:(BOOL)highlighted { return @{ NSFontAttributeName: [UIFont systemFontOfSize:10], NSForegroundColorAttributeName: [[self textColorHighlighted:highlighted] \ colorWithAlphaComponent:0.8] }; } @end // Register custom cell in your MSWeekView subclass @implementation MyWeekView - (void)setupSupplementaryViewClasses { self.eventCellClass = [CustomEventCell class]; [super setupSupplementaryViewClasses]; } @end ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.