OGeek|极客世界-中国程序员成长平台

标题: ios - 在 UITableViewCell 上创建水平渐变 [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-13 08:05
标题: ios - 在 UITableViewCell 上创建水平渐变

好的,我可以在 UITableViewCell 上对其类进行垂直渐变:

  UIView *backgroundView = [[UIView alloc] init];

  CAGradientLayer *gradient = [CAGradientLayer layer];
  gradient.frame = self.bounds;

  gradient.colors = [NSArray arrayWithObjectsid)[[UIColor redColor] CGColor],
                       (id)[[UIColor blueColor] CGColor], nil];

  [backgroundView.layer insertSublayer:gradient atIndex:1];

  [self setBackgroundView:backgroundView];

但是从左到右的水平渐变呢?



Best Answer-推荐答案


简单的文档检查:

CAGradientLayer 具有 startPointendPoint 属性。我假设您可以使用这些来定位渐变。

关于ios - 在 UITableViewCell 上创建水平渐变,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24068813/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://sqlite.in/) Powered by Discuz! X3.4