美文网首页
CAGradientLayer使用——渐变色

CAGradientLayer使用——渐变色

作者: 秋分落叶 | 来源:发表于2019-05-16 15:58 被阅读0次

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

colorView.frame = CGRectMake(0, 0, 200, 200);

colorView.center = CGPointMake(375/2.0, 667/2.0-100);

[self.view addSubview:colorView];

CAGradientLayer *gradient = [CAGradientLayer layer];

gradient.frame = colorView.bounds;

gradient.colors = @[(id)[UIColor blackColor].CGColor,(id)[UIColor whiteColor].CGColor];

gradient.startPoint = CGPointMake(0, 1);

gradient.endPoint = CGPointMake(1, 0);

gradient.locations = @[@(0.5f), @(1.0f)];

[colorView.layer addSublayer:gradient];

相关文章

网友评论

      本文标题:CAGradientLayer使用——渐变色

      本文链接:https://www.haomeiwen.com/subject/mxbiaqtx.html