0

異なるフレームで UIView に波形 (高解像度ビットマップ) をレンダリングしようとしています。スケーリングしたいので、パフォーマンスを向上させるために CATiledLayer を使用することにしました。しかし、結果として、私は予想していなかったものを得ました。

ソース ビットマップ (5000 x 80 ピクセル): ソース ビットマップ: 結果 (? x 80 ピクセル): ソース ビットマップ: トラックは同じではありません。スケーリング/スクロールを続けると、それらは異なります。

コード自体:

+ (Class)layerClass {
    return [CATiledLayer class];
}

- (id)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {

        self.loading = YES;
        self.recording = NO;

        CATiledLayer *tiledLayer = (CATiledLayer *)[self layer];
        tiledLayer.levelsOfDetail = 7;
    tiledLayer.levelsOfDetailBias = 3;
    tiledLayer.tileSize = CGSizeMake(128.0, 128.0); 

        [self addSubview:activityView];+ (Class)layerClass {
    return [CATiledLayer class];
}

-(void)drawRect:(CGRect)rect {
        UIImage* image = [UIImage imageWithContentsOfFile:self.imagePath];

        CGFloat scale = parent.frame.size.width/image.size.width;

        CGContextRef context = UIGraphicsGetCurrentContext();
        CGContextClearRect(context, rect);
        CGContextSaveGState(context);

        CGContextScaleCTM(context, scale, 1.0); 
        CGContextDrawImage(context, CGRectMake(0, 0, image.size.width, image.size.height), image.CGImage);
        CGContextRestoreGState(context);
}

- ここで何が間違っていますか? -CATiledLayer は X 軸だけでスケーリングできますか?

前もって感謝します!

4

0 に答える 0