uilabel con contorno o trazo [duplicado]
Esta pregunta ya tiene una respuesta aquí:
¿Cómo hago que UILabel muestre el texto delineado? 12 respuestasMe preguntaba cómo puedo crear trazo de texto para UILabel. ¿hay alguna manera posible? @
gracias
#import <Foundation/Foundation.h>
@interface CustomLabel : UILabel {
}
@end
#import "CustomLabel.h"
@implementation CustomLabel
- (void)drawTextInRect:(CGRect)rect {
CGSize shadowOffset = self.shadowOffset;
UIColor *textColor = self.textColor;
CGContextRef c = UIGraphicsGetCurrentContext();
CGContextSetLineWidth(c, 22);
CGContextSetTextDrawingMode(c, kCGTextStroke);
self.textColor = [UIColor whiteColor];
[super drawTextInRect:rect];
CGContextSetTextDrawingMode(c, kCGTextFill);
self.textColor = textColor;
self.shadowOffset = CGSizeMake(0, 0);
[super drawTextInRect:rect];
self.shadowOffset = shadowOffset;
//works fine with no warning
}
ahora la pregunta es cómo puedo usar esta subclase con una etiqueta IBOutlet en diferentes controladores de vista. Es correcto
label = [[CustomLabel alloc] initWithFrame:CGRectMake(0, 0, 190, 190)];