#import "UILabelCustom.h"
@implementation UILabelCustom
- (void) loadCustomFont:(NSString *)font Type:(NSString *)type MagicNumber:(int)number {
NSString *fontPath = [[NSBundle mainBundle] pathForResource:font ofType:type];
CGDataProviderRef fontDataProvider = CGDataProviderCreateWithFilename([fontPath UTF8String]);
customFont = CGFontCreateWithDataProvider(fontDataProvider);
CGDataProviderRelease(fontDataProvider);
customFontMagicNumber = number;
CGAffineTransform textTransform = CGAffineTransformMake(1.0, 0.0, 0.0, -1.0, 0.0, 0.0);
self.transform = textTransform;
}
- (void)drawRect:(CGRect)rect {
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetFont(context, customFont);
CGContextSetTextDrawingMode(context, kCGTextFillStroke);
CGContextSetRGBFillColor(context, 254.0/255.0, 245.0/255.0, 111.0/255.0, 1.0);
CGContextSetRGBStrokeColor(context, 193.0/255.0, 154.0/255.0, 0.0/255.0, 1.0);
CGContextSetFontSize(context, rect.size.height-1);
CGContextSetCharacterSpacing(context,3.0);
CGContextSetShadow(context,CGSizeMake(4,4),3.5);
int textLength = [self.text length];
CGGlyph textToPrint[textLength];
for (int i = 0; i < textLength; ++i) {
textToPrint[i] = [self.text characterAtIndex:i] - customFontMagicNumber;
}
CGContextShowGlyphsAtPoint (context,x,8,textToPrint,textLength);
}
-(void)dealloc {
[super dealloc];
}
@end