Drawing gradient over image in ios

后端 未结 5 639
天涯浪人
天涯浪人 2020-12-08 11:55

How to create gradient colour look like following image programatically.

\"enter

5条回答
  •  -上瘾入骨i
    2020-12-08 12:41

    CAGradientLayer *gradient = [CAGradientLayer layer];
    gradient.frame = self.view.bounds;
    
    
    gradient.startPoint = CGPointMake(1.0, 1.0); //Dark From bottom
    gradient.endPoint = CGPointMake(1.0, 0);
    
    
    gradient.colors = [NSArray arrayWithObjects:
                       (id)[[UIColor blackColor] CGColor],
                       (id)[[UIColor clearColor] CGColor], nil];
    
    
    [self.view.layer insertSublayer:gradient atIndex:0];
    

提交回复
热议问题