2016-08-17 4 views
2

テキストが画面から消えていくので、私のテキストビューの上をフェードアウトしようとしています。私はスターウォーズのクレジットのように見えるが、その幅を保つようにしたい。私はこのコードを使って作業していますが、画面が黒くなってしまいます。TextView。スターウォーズのようなスクリーンのようなものを消しながら、上にテキストをフェードアウトします。

if let containerView = textView.superview { 
     let gradient = CAGradientLayer(layer: containerView.layer) 
     gradient.frame = containerView.bounds 
     gradient.colors = [UIColor.clearColor().CGColor, UIColor.blueColor().CGColor] 
     gradient.startPoint = CGPoint(x: 0.0, y: 1.0) 
     gradient.endPoint = CGPoint(x: 0.0, y: 0.85) 
     containerView.layer.mask = gradient 
    } 
+3

あなたは力を使って試しましたか? –

答えて

1

私は1つのサードパーティのライブラリで同じことを実装しました。

これを試してください。 :https://github.com/somtd/SWScrollView

それはscrollview内部のTextViewを形質転換し、ここではそのためのコードです

- (void)setupScrollPerspective 
{ 
    CATransform3D transform = CATransform3DIdentity; 
    //z distance 
    float distance = [[UIScreen mainScreen] bounds].size.height; 
    float ratio = [[UIScreen mainScreen] bounds].size.height/[[UIScreen mainScreen] bounds].size.height; 
    transform.m34 = - ratio/distance; 
    transform = CATransform3DRotate(transform, 60.0f * M_PI/180.0f, 1.f, 0.0f, 0.0f); 
    self.layer.transform = transform; 
    self.layer.zPosition = distance * ratio; 
    self.layer.position = CGPointMake([[UIScreen mainScreen] bounds].size.width/2, 
             [[UIScreen mainScreen] bounds].size.height/3); 
} 

enter image description here

私はあなたが同じようなことをしたい願っています.....

+0

私はちょうどフェードアウトするトップをしたい。 – user1079052

関連する問題