You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
909 B
26 lines
909 B
1 year ago
|
//
|
||
|
// SVRadialGradientLayer.m
|
||
|
// SVProgressHUD, https://github.com/SVProgressHUD/SVProgressHUD
|
||
|
//
|
||
|
// Copyright (c) 2014-2019 Tobias Tiemerding. All rights reserved.
|
||
|
//
|
||
|
|
||
|
#import "SVRadialGradientLayer.h"
|
||
|
|
||
|
@implementation SVRadialGradientLayer
|
||
|
|
||
|
- (void)drawInContext:(CGContextRef)context {
|
||
|
size_t locationsCount = 2;
|
||
|
CGFloat locations[2] = {0.0f, 1.0f};
|
||
|
CGFloat colors[8] = {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.75f};
|
||
|
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
|
||
|
CGGradientRef gradient = CGGradientCreateWithColorComponents(colorSpace, colors, locations, locationsCount);
|
||
|
CGColorSpaceRelease(colorSpace);
|
||
|
|
||
|
float radius = MIN(self.bounds.size.width , self.bounds.size.height);
|
||
|
CGContextDrawRadialGradient (context, gradient, self.gradientCenter, 0, self.gradientCenter, radius, kCGGradientDrawsAfterEndLocation);
|
||
|
CGGradientRelease(gradient);
|
||
|
}
|
||
|
|
||
|
@end
|