iOS View设置渐变色

    _headView = [[UIView alloc] initWithFrame:CGRectMake(0, 64, _WIDTH, 200)];
    CAGradientLayer *viewALayer = [CAGradientLayer layer];
    viewALayer.frame = _headView.bounds;
    viewALayer.colors = [NSArray arrayWithObjects:
                       (id)[UIColor colorWithRed:49/255.0 green:202/255.0 blue:111/255.0 alpha:1.0].CGColor,
                       (id)[UIColor colorWithRed:123/255.0 green:222/255.0 blue:167/255.0 alpha:1.0].CGColor,
                       (id)[UIColor whiteColor].CGColor, nil];
    [_headView.layer addSublayer: viewALayer];

你可能感兴趣的:(iOS View设置渐变色)