react-native-linear-gradient/BVLinearGradient/BVLinearGradient.m

43 lines
852 B
Objective-C

#import "BVLinearGradient.h"
#import <React/RCTConvert.h>
#import <UIKit/UIKit.h>
#import <QuartzCore/QuartzCore.h>
@implementation BVLinearGradient
+ (Class)layerClass
{
return [CAGradientLayer class];
}
- (CAGradientLayer *)gradientLayer
{
return (CAGradientLayer *)self.layer;
}
- (void)setColors:(NSArray *)colorStrings
{
NSMutableArray *colors = [NSMutableArray arrayWithCapacity:colorStrings.count];
for (NSString *colorString in colorStrings) {
[colors addObject:(id)[RCTConvert UIColor:colorString].CGColor];
}
self.gradientLayer.colors = colors;
}
- (void)setStartPoint:(CGPoint)startPoint
{
self.gradientLayer.startPoint = startPoint;
}
- (void)setEndPoint:(CGPoint)endPoint
{
self.gradientLayer.endPoint = endPoint;
}
- (void)setLocations:(NSArray *)locations
{
self.gradientLayer.locations = locations;
}
@end