Skip to content

Commit 537bd0d

Browse files
committed
Adding -awakeFromNib to properly initialize label properties when inflated from xib
* Added -initialize in private section to avoid code duplication
1 parent e009fba commit 537bd0d

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

Classes/RRSGlowLabel.m

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@
99
#import "RRSGlowLabel.h"
1010

1111

12+
@interface RRSGlowLabel()
13+
- (void)initialize;
14+
@end
15+
1216
@implementation RRSGlowLabel
1317

1418
@synthesize glowColor, glowOffset, glowAmount;
@@ -24,13 +28,22 @@ - (void)setGlowColor:(UIColor *)newGlowColor
2428
}
2529
}
2630

31+
- (void)initialize {
32+
colorSpaceRef = CGColorSpaceCreateDeviceRGB();
33+
34+
self.glowOffset = CGSizeMake(0.0, 0.0);
35+
self.glowAmount = 0.0;
36+
self.glowColor = [UIColor clearColor];
37+
}
38+
39+
- (void)awakeFromNib {
40+
[self initialize];
41+
}
42+
2743
- (id)initWithFrame:(CGRect)frame {
2844
self = [super initWithFrame:frame];
2945
if(self != nil) {
30-
colorSpaceRef = CGColorSpaceCreateDeviceRGB();
31-
self.glowOffset = CGSizeMake(0.0, 0.0);
32-
self.glowAmount = 0.0;
33-
self.glowColor = [UIColor clearColor];
46+
[self initialize];
3447
}
3548
return self;
3649
}

0 commit comments

Comments
 (0)