2016-07-30 10 views
0

私はUIImageViewマスキングを行っています。私は以下のような画像の背景がほしいと思う。複数画像をマスキングしているUIImageViewにスタック

enter image description here

テキスト「ヒマラヤジェル」の下部の黒い効果を見ることができます。

画像を追加するたびにそのような効果を加えたいと思います。

誰かが解決策を知っているなら、plsの助けを借りてください。

ありがとうございます。

答えて

0

UIImageViewでグラデーションを使用できます。UIImageを変更すると、グラデーションはそのまま残ります。

- (void)addGradientToView:(UIView *)view 
{ 
    CAGradientLayer *gradient = [CAGradientLayer layer]; 
    gradient.frame = CGRectMake(0, view.frame.size.height * 0.8, view.frame.size.width, view.frame.size.height * 0.2); 
    gradient.colors = @[(id)[[UIColor clearColor] CGColor], 
         (id)[[UIColor blackColor] CGColor]]; 
    [view.layer insertSublayer:gradient atIndex:0]; 
} 

勾配は、明確な色でビュー(view.hieght * 0.8)の下で開始し、終了する黒勾配まで続けます。

関連する問題