第一种:参考自:http://www.mgenware.com/blog/?p=2396
第二种:使用QuartzCore库
CAGradientLayer *gradient = [CAGradientLayer layer]; gradient.frame = self.bounds; gradient.colors = [NSArray arrayWithObjects:(id)[UIColor colorWithHexString:@"#292931"].CGColor,(id)[UIColor colorWithHexString:@"#343a46"].CGColor, nil]; [self.layer insertSublayer:gradient above:0];
【IOS绘制渐变颜色】