美文网首页
UIButton 颜色渐变+阴影

UIButton 颜色渐变+阴影

作者: KevinChein | 来源:发表于2018-06-27 10:39 被阅读58次
    - (void)setNextStepBottomGradual{
    //渐变的按钮
    UIButton *lookBtn = [UIButton buttonWithType:(UIButtonTypeCustom)];
    lookBtn.frame = CGRectMake(200, 300,100, 100);
    [lookBtn setTitle:@"查看详情" forState:(UIControlStateNormal)];
    //[lookBtn addTarget:self action:@selector(lookBtn) forControlEvents:(UIControlEventTouchUpInside)];
    
    lookBtn.layer.shadowColor= kRGBA(239, 47, 27, 0.22).CGColor;
    
    lookBtn.layer.shadowOffset=CGSizeMake(4, 4);
    lookBtn.layer.shadowOpacity=1;
    lookBtn.layer.shadowRadius= 5;
    
    //渐变颜色
    CAGradientLayer *gradientLayer = [CAGradientLayer layer];
    
    gradientLayer.colors = @[
                             (id)kRGBA(255, 66, 73, 1).CGColor,
                             (id)kRGBA(236, 24, 32, 1).CGColor
                             ];
    
    gradientLayer.locations = @[@0.3, @1.0];
    gradientLayer.startPoint = CGPointMake(0, 0);
    gradientLayer.endPoint = CGPointMake(1.0, 0);
    gradientLayer.frame = CGRectMake(0, 0,  100, 100);
    gradientLayer.cornerRadius = 50;
    [lookBtn.layer addSublayer:gradientLayer];
    [self.view addSubview:lookBtn];
    }
    

    图片.png

    相关文章

      网友评论

          本文标题:UIButton 颜色渐变+阴影

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