I am getting this error:
Undefined symbols for architecture i386: "_OBJC_CLASS_$_CAGradientLayer", referenced from: objc-class-ref in GradientButton.o ld: symbol(s) not found for architecture i386 clang: error: linker command failed with exit code 1 (use -v to see invocation)
while trying to make a subclass of UIButton:
this is the h file:
#import <UIKit/UIKit.h>
#import <QuartzCore/QuartzCore.h>
@interface GradientButton : UIButton
@property (assign, nonatomic) int borderWidth;
@property (assign, nonatomic) UIColor *buttonColor;
@property (strong, nonatomic) UIColor *borderColor;
@property (strong, nonatomic) NSString *title;
- (id)initWithFrame:(CGRect)frame botderWidth:(int)width borderColor:(UIColor *)bColor buttonColor:(UIColor *)btnColor title:(NSString *)btnTitle;
@end
this is the m file:
#import "GradientButton.h"
@interface GradientButton (Private)
- (void)initBorder;
- (void)initCorners;
- (void)initColorsAndFont;
- (void)initStyle;
- (void)initGradient;
@end
@implementation GradientButton
@synthesize borderColor, borderWidth, title, buttonColor;
- (id)initWithFrame:(CGRect)frame botderWidth:(int)width borderColor:(UIColor *)bColor buttonColor:(UIColor *)btnColor title:(NSString *)btnTitle
{
borderWidth = width;
borderColor = bColor;
title = btnTitle;
buttonColor = btnColor;
[self initBorder];
[self initCorners];
[self initColorsAndFont];
[self initStyle];
[self initGradient];
return self;
}
- (void)initBorder {
self.layer.borderWidth = borderWidth;
self.layer.borderColor = borderColor.CGColor;
}
- (void)initCorners {
self.layer.cornerRadius = self.frame.size.height / 2.0f;
}
- (void)initColorsAndFont {
self.backgroundColor = buttonColor;
[self setTitle:title forState:UIControlStateNormal];
self.titleLabel.font = [UIFont boldSystemFontOfSize:17];
[self setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
}
- (void)initStyle {
self.layer.shadowColor = [UIColor darkGrayColor].CGColor;
self.layer.shadowOpacity = 1.0;
self.layer.shadowOffset = CGSizeMake(2.0, 2.0);
}
- (void)initGradient {
CAGradientLayer *layer = [CAGradientLayer layer];
NSArray *colors = [NSArray arrayWithObjects:
(id)[UIColor whiteColor].CGColor,
(id)buttonColor,
nil];
[layer setColors:colors];
[layer setFrame:self.bounds];
[self.layer insertSublayer:layer atIndex:0];
[self setClipsToBounds:YES];
}
@end
Why???