0
進出口試圖創建一個UILabel子類,將完成2個獨立的UILabels我已經堆疊在使用以下方法彼此的頂部上的任務:創建行程和陰影影響僅使用1的UILabel子類
背景的UILabel :
- (void)drawTextInRect:(CGRect)rect {
CGSize shadowOffset = self.shadowOffset;
//UIColor *textColor = self.textColor;
CGContextRef c = UIGraphicsGetCurrentContext();
CGContextSetLineWidth(c, 3);
CGContextSetTextDrawingMode(c, kCGTextStroke);
self.textColor = [UIColor whiteColor];
[super drawTextInRect:rect];
self.alpha = .1;
self.shadowOffset = shadowOffset;
}
前景的UILabel:
- (void)drawTextInRect:(CGRect)rect {
CGSize shadowOffset = self.shadowOffset;
UIColor *textColor = self.textColor;
CGContextRef c = UIGraphicsGetCurrentContext();
CGContextSetLineWidth(c, 2);
CGContextSetTextDrawingMode(c, kCGTextStroke);
self.textColor = [UIColor blackColor];
[super drawTextInRect:rect];
CGContextSetTextDrawingMode(c, kCGTextFill);
self.textColor = textColor;
self.shadowOffset = CGSizeMake(0, 0);
[super drawTextInRect:rect];
self.alpha = .5;
self.shadowOffset = shadowOffset;
}
有沒有辦法做到這2套影響使用僅1的UILabel子類的?