我已经用下面的代码子类化了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