如何在CATextlayer上重写?

时间:2015-11-06 10:34:08

标签: objective-c xcode calayer catextlayer

我正在使用CATextLayer进行自定义日历设计。我正在使用CAlayer为每个月绘制数字。但是当我按下一个按钮移动到下个月时,日期会重叠。我尝试删除子图层但没有用。请帮帮我......

Initial Calendar

但是当我搬到12月份的时候。日期重叠

enter image description here

我使用的代码是:

 [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];

0 个答案:

没有答案