Today do project encounter a UI effect, give the font plus a white edge, it looks like a background, the idea is to inherit a Uilabel, re-write the Drawtextinrect method, you can simply achieve this effect, on the code:
1 //2 //HGLLABEL.M3 //xxxxxxxxxx.xxx4 //5 //Created by xxxxx on 2017/12/23.6 //Copyright 2017 xxxx. All rights reserved.7 //8 9 #import "HGLLabel.h"Ten One @implementationHgllabel A -- (void) Drawtextinrect: (cgrect) rect { -Cgsize Shadowoffset =Self.shadowoffset; theUicolor *textcolor =Self.textcolor; - -Cgcontextref C =Uigraphicsgetcurrentcontext (); -Cgcontextsetlinewidth (c,8.0);//width of Font edge + Cgcontextsetlinejoin (c, kcglinejoinround); - + Cgcontextsettextdrawingmode (c, kcgtextstroke); ASelf.textcolor = [Uicolor Whitecolor];//Color of Font edge plus at [Super Drawtextinrect:rect]; - - Cgcontextsettextdrawingmode (c, Kcgtextfill); -Self.textcolor =TextColor; -Self.shadowoffset = Cgsizemake (0,0); - [Super Drawtextinrect:rect]; in -Self.shadowoffset =Shadowoffset; to } + - @end
The note is very clear, not much to say.
IOS adds a colored border to the Uilabel font