渐变色主要使用类:CAGradientLayer; 直接上代码:
UIColor *color = [UIColor colorWithWhite:2.0 alpha:0.1];CAGradientLayer *gradientLayer = [CAGradientLayer layer];gradientLayer.frame = self.tableView.bounds;//设置颜色数组gradientLayer.colors =@[(__bridge id)color.CGColor, (__bridge id)[UIColor orangeColor].CGColor];//设定变色位置数组gradientLayer.locations = @[@0.8];//设置变化范围gradientLayer.endPoint = CGPointMake(0.0, 1.0);gradientLayer.startPoint = CGPointMake(0.0, 0.0);//添加到根视图控制器的layer上[self.view.layer addSublayer:gradientLayer];效果图:
新闻热点
疑难解答