iOS 边框渐变+圆角

  • 内容
  • 评论
  • 相关

    self.bottomView.backgroundColor = [UIColor colorWithWhite:1 alpha:0.1];
    CAGradientLayer *gradientLayer = [CAGradientLayer layer];
    gradientLayer.frame = self.bottomView.bounds;
    gradientLayer.colors = @[(id)[UIColor colorWithHexString:@"#CD66FD"].CGColor, (id)[UIColor colorWithHexString:@"#05DFF8"].CGColor];

    CAShapeLayer *maskLayer = [CAShapeLayer layer];
    maskLayer.lineWidth = 1.0;
    maskLayer.path = [UIBezierPath bezierPathWithRoundedRect:self.bottomView.bounds cornerRadius:6.0].CGPath;
//    maskLayer.path = [UIBezierPath bezierPathWithRect:self.bottomView.bounds].CGPath;
    maskLayer.fillColor = [UIColor clearColor].CGColor;
    maskLayer.strokeColor = [UIColor blackColor].CGColor;
    maskLayer.cornerRadius = 6.0; // 添加圆角

    
    gradientLayer.mask = maskLayer;
    [self.bottomView.layer addSublayer:gradientLayer];

评论

0条评论

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注