@interface UIStrokeLabel : UILabel
@property (nonatomic, assign) CGFloat stokeWidth;
@end
@implementation UIStrokeLabel
- (void)drawTextInRect:(CGRect)rect{
self.attributedText = [[NSAttributedString alloc]
initWithString:self.text
attributes:@{
NSStrokeWidthAttributeName: [NSNumber numberWithFloat:self.strokeWidth],
NSStrokeColorAttributeName:[UIColor blueColor],
NSForegroundColorAttributeName:self.textColor
}
];
[super drawTextInRect:rect];
}
@end
self.strokeWidth must be under 0.
if it is over 0, text fore color is transparent.
댓글 없음:
댓글 쓰기