我正在使用 CATextLayer 进行自定义日历设计。我正在使用 CAlayer 来绘制每个月的数字。但是当我按下下一个按钮移动到下个月时,日期是重叠的。我尝试删除子层但没有用。请帮帮我。。
但是当我搬到十二月时。日期重叠
我使用的代码是:
[date sizeWithAttributes:@{ NSFontAttributeName : [UIFont fontWithName:@"HelveticaNeue-Light" size:10.0] }];
self.mainLayer = [self layer];
[self.mainLayer setRasterizationScale:[[UIScreen mainScreen] scale]];
self.messageLayer = [CATextLayer layer];
[self.messageLayer setForegroundColor:[[UIColor blackColor] CGColor]];
[self.messageLayer setContentsScale:[[UIScreen mainScreen] scale]];
[self.messageLayer setFrame:CGRectMake(targetX+2, targetY+10, kVRGCalendarViewDayWidth, kVRGCalendarViewDayHeight)];
[self.messageLayer setString:date];
self.messageLayer.font = (__bridge CFTypeRef)@"HelveticaNeue-Bold";
messageLayer.fontSize = 10;
messageLayer.alignmentMode = kCAAlignmentCenter;
[mainLayer addSublayer:messageLayer];
[mainLayer setShouldRasterize:YES];