渐变色的背景颜色

//渐变背景色

    UIView *layerview = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, 0.5*kScreenHeight)];

    CAGradientLayer *gradientlayer = [CAGradientLayer layer];

    gradientlayer.bounds = layerview.bounds;

    gradientlayer.borderWidth = 0;

    gradientlayer.frame = layerview.bounds;

    gradientlayer.colors = [NSArray arrayWithObjects:(id)[UIColor colorWithRed:233/255.0 green:73/255.0 blue:82/255.0 alpha:1.0].CGColor,(id)[UIColor colorWithRed:153/255.0 green:0 blue:110/255.0 alpha:1.0].CGColor, nil];

    gradientlayer.startPoint = CGPointMake(0, 0);

    gradientlayer.endPoint = CGPointMake(0, 1);

    [layerview.layer insertSublayer:gradientlayer atIndex:0];

    [imageView addSubview:layerview];



效果图:(红到紫红,由于Flashplayer版本问题,无法添加图片,等下次再补上)

你可能感兴趣的:(渐变色的背景颜色)