1

内部で UILabel の編集を開始すると、丸い長方形であるはずのカスタム UIView があります (CAShapeLayer マスク パスとアウトライン パスの CABasic アニメーション)。明確にするために、カスタム UIView は次のように編成されます。

MyCustomView には ClipView があります。ClipView は drawRect を使用して、丸い四角形の背景を描画します。(clipview == 切り取られるビュー)

次に、次のコードを呼び出して CAShapeLayer 操作を行います。

//0. CLIP

shapeLayer = [CAShapeLayer layer];
CGRect shapeRect = self.bounds;
[shapeLayer setBounds:shapeRect];
[shapeLayer setPosition:CGPointMake((shapeRect.size.width)/2.0f, (shapeRect.size.height)/2.0f)];
[shapeLayer setFillColor:[[UIColor colorWithRed:0 green:1 blue:0 alpha:1.0f] CGColor]];
[shapeLayer setStrokeColor:[[UIColor redColor] CGColor] ];
[shapeLayer setLineWidth:1];
[shapeLayer setLineJoin:kCALineJoinRound];
[shapeLayer setOpacity:1];


CGRect shapeLayerPathRect = CGRectMake(0, 0, self.bounds.size.width, 44.0f);
shapeLayer.path = [self roundRectPathForRectangle:shapeLayerPathRect andRadius:CORNER_RADIUS];
[[self.clipView layer] setMask:shapeLayer];

//1. draw the shaded outline of a round rectangle
outlineLayer = [self topDownShadowShapeLayer]; //setup for my CAShapeLayer, involving shadow stuff, line color, etc
outlineLayer.path = [self roundRectPathForRectangle:shapeLayerPathRect andRadius:CORNER_RADIUS];
[self.clipView.layer addSublayer:outlineLayer];

進行中のアニメーションは最も速いアプローチ (両方の CAShapeLayers をストレッチする) ですが、要素全体 (MyCustomView) によってすべてが大幅に遅くなります! たとえば、進行中の UIView アニメーションは、MyCustomView が ScrollView 内にある場合も非常に不安定です。

私は主に UIScrollView の問題について心配しています。UIScrollView がこれらのレイヤーを変換するのに、なぜ途切れ途切れになるのでしょうか? 良い解決策はありますか / 同じ効果を達成できる別のアプローチは何ですか?

4

0 に答える 0