美文网首页
iOS UIView的简单渐变效果

iOS UIView的简单渐变效果

作者: CGsir陈 | 来源:发表于2022-09-15 14:17 被阅读0次

    UIView *view1 =[[UIView alloc] initWithFrame:CGRectMake(0, 0, 100, 30)];
    [self.view addSubview:view1];
    CAGradientLayer *gl = [CAGradientLayer layer];
    gl.frame = view1.bounds;
    gl.startPoint = CGPointMake(0, 0.5);
    gl.endPoint = CGPointMake(1, 0.5);
    gl.colors = @[(__bridge id)HEXCOLOR(0xFFE998).CGColor,(__bridge id)HEXCOLOR(0xFFD22F).CGColor];
    gl.locations = @[@(0.0),@(1.0f)];
    [view1.layer insertSublayer:gl atIndex:0];

    相关文章

      网友评论

          本文标题:iOS UIView的简单渐变效果

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