Draw a dashed line

Source: Internet
Author: User
Tags dashed line

draw a dashed line

cashapelayer *shapelayer = [cashapelayer layer];

[Shapelayer setbounds:self. Backview. Bounds];

[Shapelayer setposition:self. Backview. Center];

[Shapelayer setfillcolor: [[uicolor clearcolor] cgcolor];

// set dashed color to blackcolor

[Shapelayer setstrokecolor: [[uicolor blackcolor] cgcolor];

[Shapelayer setstrokecolor: [[uicolor colorwithred:223/255.0 Green :223/255.0 Blue:223/255.0 Alpha:1.0f] Cgcolor]];

//3.0f Set the width of the dashed line

[Shapelayer setlinewidth:0.5f];

[Shapelayer setlinejoin:kcalinejoinround];

//3= line width 1= The spacing of each line

[Shapelayer setlinedashpattern:

[nsarray arraywithobjects: [nsnumber numberwithint:4],

[nsnumber numberwithint:2],Nil]];

// set path

cgmutablepathref Path = cgpathcreatemutable();

cgpathmovetopoint (path, nullself. Coupnumberlabel. Frame. Origin. X + self. Coupnumberlabel. Frame. Size. Width10 x  dashed x axis start   y  dashed y axis start

Cgpathaddlinetopointnull,self. Coupnumberlabel. Frame. Origin. X + self. Coupnumberlabel. Frame. Size. Width,164/2- 10);   //x  dashed X axis start   y  dashed height

[Shapelayer SetPath:p ath];

cgpathrelease(path);

[Self layer] addsublayer: Shapelayer];

Draw a dashed line

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.