0

UIImageView の上にある UITextView に (テキストの配列から) テキストを表示する Interface Builder を使用して、iOS6 用のアプリを作成しています。ユーザーは右または左にスワイプして、配列内の別のテキストに変更できます。

現在、次のコードを使用しています。

    CATransition *transition = [CATransition animation];
    transition.duration = 0.25;
    transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
    transition.type = kCATransitionPush;
    transition.subtype =kCATransitionFromRight;
    transition.delegate = self;
    [self.view.layer addAnimation:transition forKey:nil];
    [self.view addSubview:self.text];

ユーザーがスワイプすると、UITextView、UIImageView、およびすべての画面がアニメーション化されます。ユーザーがスワイプしたときにテキストのみを左右に移動させ、UIImageView をそのままにしておくにはどうすればよいですか?

4

2 に答える 2

2

左に移動するには、このアニメーションを使用します。

 [UIView animateWithDuration:1 
                 animations:^{
                     [yourTextView setFrame:CRectMake(-yourTextView.frame.size.width,yourTextView.frame.origin.y,yourTextView.frame.size.width,yourTextView.frame.size.height)];
                 }
                 completion:^(BOOL finished){
                     //do something after completion if needed
                     //new text to uitextView.
                 }];

右に移動するには、このアニメーションを使用します。

[UIView animateWithDuration:1 
                 animations:^{
                     [yourTextView setFrame:CRectMake(self.view.frame.size.width+yourTextView.frame.size.width,yourTextView.frame.origin.y,yourTextView.frame.size.width,yourTextView.frame.size.height)];
                 }
                 completion:^(BOOL finished){
                     //do something after completion if needed
                     //new text to uitextView.
                 }];
于 2012-12-01T07:14:55.353 に答える
1

UITextviewのレイヤーでアニメーションを追加します。[YourTextView.layer addAnimation:transition forKey:nil];

于 2012-12-01T09:49:32.780 に答える