0

I am new to programming, I am using FScalendar and I want to change days name into two alphabets i.e. (SU,MO,TU.....), and I want to remove the gaps between cells?

I have tried in given area but not found the solution:

@property (weak, nonatomic) FSCalendarAppearance *appearance;

I have attached image for reference in which gaps are visible clearly.

enter image description here

Does this code need to be changed to get zero gap between cells???????

// Calculate item widths and lefts
    free(self.widths);
    self.widths = ({
        NSInteger columnCount = 7;
        size_t columnSize = sizeof(CGFloat)*columnCount;
        CGFloat *widths = malloc(columnSize);
        CGFloat contentWidth = self.collectionView.fs_width - self.sectionInsets.left - self.sectionInsets.right;
        FSCalendarSliceCake(contentWidth, columnCount, widths);
        widths;
    });

    free(self.lefts);
    self.lefts = ({
        NSInteger columnCount = 7;
        size_t columnSize = sizeof(CGFloat)*columnCount;
        CGFloat *lefts = malloc(columnSize);
        lefts[0] = self.sectionInsets.left;
        for (int i = 1; i < columnCount; i++) {
            lefts[i] = lefts[i-1] + self.widths[i-1];
        }
        lefts;
    });

    // Calculate item heights and tops
    free(self.heights);
    self.heights = ({
        NSInteger rowCount = self.calendar.transitionCoordinator.representingScope == FSCalendarScopeWeek ? 1 : 6;
        size_t rowSize = sizeof(CGFloat)*rowCount;
        CGFloat *heights = malloc(rowSize);
        if (!self.calendar.floatingMode) {
            CGFloat contentHeight = self.collectionView.fs_height - self.sectionInsets.top - self.sectionInsets.bottom;
            FSCalendarSliceCake(contentHeight, rowCount, heights);
        } else {
            for (int i = 0; i < rowCount; i++) {
                heights[i] = self.estimatedItemSize.height;
            }
        }
        heights;
    });

    free(self.tops);
    self.tops = ({
        NSInteger rowCount = self.calendar.transitionCoordinator.representingScope == FSCalendarScopeWeek ? 1 : 6;
        size_t rowSize = sizeof(CGFloat)*rowCount;
        CGFloat *tops = malloc(rowSize);
        tops[0] = self.sectionInsets.top;
        for (int i = 1; i < rowCount; i++) {
            tops[i] = tops[i-1] + self.heights[i-1];
        }
        tops;
    });

source file ------>. FSCalendarCollectionViewLayout.m

ABTech
  • 1
  • 1
  • 4

2 Answers2

1

enter image description here You can do this by adding a subview in fscalendar for weekDays. I ADDED SINGLE LETTER BUT YOU CAN ADD according to your requirements. 1- create Viewenter image description here

2- enter image description here

3-

let week_days_view = weekDaysView.instanceFromNib() as! weekDaysView
    week_days_view.frame = self.fsCalendar.calendarWeekdayView.frame
    self.fsCalendar.calendarWeekdayView.addSubview(week_days_view)
AyAz
  • 2,027
  • 2
  • 21
  • 28
0

@ABTech Regarding this I want to change days name into two alphabets i.e. (SU,MO,TU.....), Try with modification on FSCalendarWeekdayView.m file on it's - (void)configureAppearance method on FSCalendar library.In Swift check here

NSString * str = [weekdaySymbols[index] uppercaseString];
label.text = [str substringToIndex:2];

And Regarding this I want to remove the gaps between cells?, Try this like below, Yes you need to try this @property (weak, nonatomic) FSCalendarAppearance *appearance;

    calendar.appearance.titleOffset = CGPoint.init(x: -50, y: 0.0)
    calendar.appearance.eventOffset = CGPoint.init(x: -50, y: 0.0)
Ram
  • 764
  • 1
  • 7
  • 20
  • This given code is to change offset of dates text, if it is applied, it will change the position of text only. And due tot his some dates got hide also. – ABTech Mar 04 '20 at 07:24
  • @ABTech Then you should be define a custom cell with your desired leading space between the cells and should be register like on that library on your source `calendar.register(YourCalendarCustomCell.self, forCellReuseIdentifier: "cell")` – Ram Mar 04 '20 at 07:30