ios - 视图 渐变

//
//  YViewGradient.m
//  AoleYou20170907
//
//  Created by XY IOS on 2018/4/25.
//  Copyright © 2018年 -陈诗友. All rights reserved.
//

#import "YViewGradient.h"

@implementation YViewGradient


/**
 按钮渐变

 @param viewid 按钮
 */
+(void)changeAlphaWithviewID:(UIButton *)viewid{
    CAGradientLayer *_gradLayer = [CAGradientLayer layer];
    NSArray *colors = [NSArray arrayWithObjects:
                       (id)[[UIColor colorWithWhite:0 alpha:1] CGColor],
                       (id)[[UIColor colorWithWhite:0 alpha:0.8] CGColor],
                       (id)[[UIColor colorWithWhite:0 alpha:0.6] CGColor],
                       nil];
    [_gradLayer setColors:colors];
    //渐变起止点,point表示向量
    [_gradLayer setStartPoint:CGPointMake(1.0f, 0.0f)];
    [_gradLayer setEndPoint:CGPointMake(0.0f, 0.0f)];
    [_gradLayer setFrame:viewid.bounds];
    [viewid.layer setMask:_gradLayer];
}
@end

猜你喜欢

转载自www.cnblogs.com/shenlaiyaoshi/p/8945215.html