iOS text stroke

Source: Internet
Author: User

It can be hard to see when the label is dry with the font of the system, and sometimes we need to stroke the text to make it more beautiful.

If you want to use text to have a stroke, let your label inherit from Ctwblabe, and the text color and stroke color can be customized.

Not much nonsense, directly on the code:

//

ctwblabel.m

Speedpro

//

Created by Wbapple on 16/5/17.

COPYRIGHT©2016 year Huawei. All rights reserved.

//

#import "CTWBLabel.h"

@implementation Ctwblabel

/**

* Overriding parent class text method

*

* @param rect text strokes

*/

-(void) Drawtextinrect: (cgrect) rect

{

Strokes

Cgcontextref C = Uigraphicsgetcurrentcontext ();

Cgcontextsetlinewidth (c, 10);

Cgcontextsetlinejoin (c, Kcglinejoinround);

Cgcontextsettextdrawingmode (c, Kcgtextstroke);

Stroke color

Self.textcolor = [Uicolor colorwithhexstring:@ "#29a5e5"];

[Super Drawtextinrect:rect];

Text color

Self.textcolor = [Uicolor colorwithhexstring:@ "#ffb901"];

Cgcontextsettextdrawingmode (c, Kcgtextfill);

[Super Drawtextinrect:rect];

}

@end

iOS text stroke

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.