1

I'm making a calendar view using UITableView (see image below), each UITableViewCell represent a month with several subviews and each subview means one day let's call it a DayView, every DayView contains a subview UILabel to show the day of the month. Until now, everything seems good, and the scrolling of UITableView is smoothly. But after I add this line in the DayView's - (instancetype)initWithFrame:(CGRect)frame:

self.layer.cornerRadius = 5.0;

The UITableView's frame rate become much lower when scrolling. It can't catch up my finger at all. So what is the most likely cause?

By the way, what should I do to resolve this kind of problem?

Thanks.

Edit:

The cellForRowAtIndexPath method:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    static NSString *monthCellIdentifier = @"MonthCell";
    OPCalendarPageView *cell = [tableView dequeueReusableCellWithIdentifier:monthCellIdentifier];
    cell.manager = _manager;
    cell.date = [self dateForIndexPath:indexPath];
    return cell;
}

And I'm using the library JTCalendar, OPCalendarPageView is a custom version of JTCalendarPageView, just added a month label above the first day of month.

screenshot

Hong Duan
  • 4,234
  • 2
  • 27
  • 50

1 Answers1

1

First of all, please mention bit more , like scenario of your sub-views or rather than setting corner radius what other properties you have set like border-width or masktobound or cliptobound or etc.

secondly, I am not sure but i had solved my issue with setting just following line

self.layer.masksToBounds = YES;

or if this solution does not work then try following link in which fknrdcls gave very good answer in proper way regarding to protect corner radius negative impact on uitableview.
basically uitableview is subclass of uiscrollview so, below solution might be solve your problem.

UILabel layer cornerRadius negatively impacting performance

Community
  • 1
  • 1
Badal Shah
  • 7,541
  • 2
  • 30
  • 65