2015-09-25 126 views
1

我使用UITableView制作日历视图(见下图),每个UITableViewCell代表一个月有几个子视图,每个子视图代表有一天我们称它为DayView ,每DayView包含子视图UILabel来显示月份的一天。到现在为止,一切似乎都很好,并且UITableView的滚动顺利。但经过我在添加此行DayView- (instancetype)initWithFrame:(CGRect)frameiOS UITableView在设置子视图的layer.cornerRadius后不顺利滚动

self.layer.cornerRadius = 5.0; 

的UITableView中的帧速率成为滚动时要低得多。它根本无法追上我的手指。那么最可能的原因是什么?

顺便说一句,我该怎么做才能解决这类问题?

谢谢。

编辑:

cellForRowAtIndexPath方法:

- (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; 
} 

而我使用的库JTCalendarOPCalendarPageViewJTCalendarPageView一个定制版本,只是增加了一个月的第一天以上一个月的标签。

screenshot

+0

为什么你需要圆角每天看法? – rmaddy

+0

请为以下代码添加-cellForRowAtIndexpath代码: – Johnykutty

+0

@rmaddy我只是想让日视图的形状不是矩形,而是发现了这个问题。 –

回答

1

首先,请提多一点,像你的子视图或,而不是设置什么其他属性已设置像边框宽度或masktobound或cliptobound或等

圆角半径方案

其次, 我不知道,但我已经解决了我的问题与刚才设置以下行

self.layer.masksToBounds = YES;

如果此搜索解决方案n不工作,然后尝试以下链接,其中fknrdcls关于保护角落半径对uitableview的负面影响给予了很好的回答。
基本上uitableview是uiscrollview的子类,所以下面的解决方案可能会解决你的问题。

UILabel layer cornerRadius negatively impacting performance

+0

这真的有诀窍,太棒了! –