通过颜色来生成一个纯色图片
1
2
3
4
5
6
7
8
9
10
- (UIImage *)buttonImageFromColor:(UIColor *)color{
    CGRect rect = CGRectMake(0, 0, self.frame.size.width, self.frame.size.height);
    UIGraphicsBeginImageContext(rect.size);
    CGContextRef context = UIGraphicsGetCurrentContext();
    CGContextSetFillColorWithColor(context, [color CGColor]);
    CGContextFillRect(context, rect);
    UIImage *img = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    return img;
}

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-05-31
  • 2021-08-21
  • 2022-12-23
  • 2021-07-10
  • 2021-12-14
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-10-28
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案