-13

iOSの「スターウォーズ」オープニングクロールのやり方は?CSS3 (3D 変換) でやろうとしましたが、非常に遅いです。Objective-Cでそれを行うことは可能ですか?

Objective-Cでの書き方を教えてください!

4

1 に答える 1

15

Objective-Cでは可能です。

優しいからこそ

簡単な回転から始めて、何が起こるか見てみましょう。構築すると、良い回転が得られたことがわかりますが、現実的ではありません。実際の効果を得るには、遠近法も歪める必要があります。

UITextView *textView = [[UITextView alloc] initWithFrame:self.view.bounds];
[textView setAutoresizingMask:UIViewAutoresizingFlexibleHeight|UIViewAutoresizingFlexibleWidth];
[textView setBackgroundColor:[UIColor blueColor]];

[textView setText:@"Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum."];

[textView setFont:[UIFont boldSystemFontOfSize:32.0]];
[textView setTextAlignment:NSTextAlignmentCenter];

// Rotate the text
[textView.layer setTransform:CATransform3DMakeRotation(M_PI_4, 1.0, 0.0, 0.0)];

// Now we need to skew the box so the bottom is wider than the top.

[self.view addSubview:textView];

そこに着く!

よし、ちょっとググった後、CATransform3D探している遠近感を調整するために の m34 値を調整する方法を見つけました。色も適当に作りました!それを構築すると、私たちがどこに向かっているのかがはっきりとわかります。ただし、フレームが画面いっぱいになるようにフレームを調整する必要があります。次に、自動スクロール アニメーションを追加して、指でスクロールする必要がないようにします。

// Learn the basics of matrix transforms: http://markpospesel.wordpress.com/tag/catransform3d/

UITextView *textView = [[UITextView alloc] initWithFrame:CGRectInset(self.view.bounds, 32.0, 32.0)];
[textView setAutoresizingMask:UIViewAutoresizingFlexibleHeight|UIViewAutoresizingFlexibleWidth];
[textView setBackgroundColor:[UIColor blackColor]];
[textView setTextColor:[UIColor yellowColor]];
[textView setEditable:NO];

[textView setText:@"Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum."];

[textView setFont:[UIFont boldSystemFontOfSize:36.0]];
[textView setTextAlignment:NSTextAlignmentCenter];

// Start with a blank transform
CATransform3D blankTransform = CATransform3DIdentity;

// Skew the text
blankTransform.m34 = -1.0 / 500.0;

// Rotate the text
blankTransform = CATransform3DRotate(blankTransform, 45.0f * M_PI / 180.0f, 1.0f, 0.0f, 0.0f);

// Set the transform
[textView.layer setTransform:blankTransform];

[self.view addSubview:textView];
于 2013-03-19T13:41:46.057 に答える