개발/아이오에스

objective-c ] UIView CAGradientLayer gradient - 적용하기

dev.jake 2021. 10. 20. 16:40

CAGradientLayer *gradient = [CAGradientLayer layer];

    [gradient setStartPoint:CGPointMake(0.0, 0.0)];

    [gradient setEndPoint: CGPointMake(1.0, 1.0)];

    

    UIColor *color1 = [UIColor colorWithRed:5.0f/255.0f green:135.0f/255.0f blue:234.0f/255.0f alpha:1.0f];

    UIColor *color2 = [UIColor colorWithRed:0.0f/255.0f green:179.0f/255.0f blue:230.0f/255.0f alpha:1.0f];

    gradient.colors = @[(id)color1.CGColor, (id)color1.CGColor, (id)color1.CGColor, (id)color2.CGColor];

      

    gradient.frame = _topView.bounds;

    

    [_topView.layer insertSublayer:gradient atIndex:0];