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

43 lines
816 B
Mathematica
Raw Normal View History

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