我已經用下面的代碼子類化了UILabel,它工作正常 - 但是任何涉及子類的動畫運行速度比普通UILabels慢很多。我假設Quartz是罪魁禍首,但是我能做些什麼來加快速度?iOS - 在iPhone 4S上緩慢動畫(但在模擬器上很好)
- (void)drawTextInRect:(CGRect)rect
{
CGSize shadowOffset = self.shadowOffset;
UIColor *textColor = self.textColor;
// Establish the Quartz 2D drawing destination:
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetLineWidth(context, 1);
CGContextSetLineJoin(context, kCGLineJoinRound);
// Draw the label’s outline:
CGContextSetTextDrawingMode(context, kCGTextStroke);
self.textColor = [UIColor whiteColor];
[super drawTextInRect:rect];
// Draw the label:
CGContextSetTextDrawingMode(context, kCGTextFill);
self.textColor = [UIColor textColor];
self.shadowOffset = CGSizeMake(0, 0);
[super drawTextInRect:rect];
self.shadowOffset = shadowOffset;
}
我同意康拉德。優秀的加法。 – MobileOverlord 2012-02-08 01:40:09