43 lines
1.3 KiB
Objective-C
43 lines
1.3 KiB
Objective-C
//
|
|
// SHineLabel.m
|
|
// GIGA
|
|
//
|
|
// Created by lianxiang on 2018/9/4.
|
|
// Copyright © 2018年 com.giga.ios. All rights reserved.
|
|
//
|
|
|
|
#import "SHineLabel.h"
|
|
|
|
@implementation SHineLabel
|
|
|
|
- (instancetype)init
|
|
{
|
|
self = [super init];
|
|
if (self) {
|
|
|
|
}
|
|
return self;
|
|
}
|
|
|
|
-(void)drawRect:(CGRect)rect{
|
|
|
|
CGContextRef ctx = UIGraphicsGetCurrentContext();
|
|
CGContextSetStrokeColorWithColor(ctx, self.outLineColor.CGColor);
|
|
CGContextSetFillColorWithColor(ctx, self.oinsideColor.CGColor);
|
|
CGContextSetLineWidth(ctx, self.font.pointSize /60.0);
|
|
CGContextSetShadowWithColor(ctx, CGSizeMake(0, 0), self.font.pointSize / 3 , self.blurColor.CGColor);
|
|
CGTextDrawingMode mode = !self.outLineColor ? kCGTextFill:(!self.oinsideColor ? kCGTextStroke:kCGTextFillStroke);
|
|
CGContextSetTextDrawingMode(ctx, mode);
|
|
NSMutableParagraphStyle *paragraStyle = [[NSMutableParagraphStyle alloc] init];
|
|
paragraStyle.alignment = NSTextAlignmentCenter;
|
|
[self.text drawInRect:self.bounds withAttributes:@{NSFontAttributeName:[UIFont fontWithName:@"PingFangSC-Semibold" size:self.fontsize],NSForegroundColorAttributeName:[UIColor whiteColor],NSKernAttributeName:@(4),NSParagraphStyleAttributeName:paragraStyle}];
|
|
|
|
}
|
|
-(void)dealloc{
|
|
self.outLineColor = nil;
|
|
self.oinsideColor = nil;
|
|
self.blurColor = nil;
|
|
|
|
}
|
|
@end
|