[Solved] Objective-C “Star Wars” opening crawl [closed]


It is possible in Objective-C.

Only because I’m nice

We’ll start with a simple rotation and see what happens. If you build, you’ll see that we got a nice rotation but it doesn’t look realistic. We need to skew the perspective as well to get the real effect.

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];

Getting there!

Alright, after a bit of googling, we’ve figured out how to adjust the m34 value of CATransform3D to adjust the perspective we’re looking for. Also made the colors right! Build it and you’ll clearly see where we’re going. But we need to adjust the frame to make sure it fills the screen. Then we could add some automated scrolling animation so we don’t have to scroll with our finger.

// 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];

7

solved Objective-C “Star Wars” opening crawl [closed]