UIImageView *imG = [[UIImageView alloc]initWithFrame:CGRectMake(0, 64, 200, 300)];
imG.image = [UIImage imageNamed:@"1.jpg"];
[self.view addSubview:imG];
/* - - - - - - CAGradientLayer - - - - - - */
CAGradientLayer *layer = [[CAGradientLayer alloc] init];
layer.frame = imG.bounds;
layer.colors = @[(__bridge id)[UIColor clearColor].CGColor,
(__bridge id)[UIColor redColor].CGColor,
(__bridge id)[UIColor clearColor].CGColor
];
layer.locations = @[@0.25,@0.5,@0.75];
layer.startPoint = CGPointMake(0, 0);
layer.endPoint = CGPointMake(1, 1);
/* - - - - - - 添加CAGradientLayer - - - - - - */
UIView *containerView = [[UIView alloc] initWithFrame:imG.bounds];
[containerView.layer addSublayer:layer];
imG.maskView = containerView;