Draw a line in IOS

Source: Internet
Author: User
Tags map class

In my project, a new uiview class is created after the map class.

. H file

# Import <uikit/uikit. h>

# DEFINE _ weith 320/3.

# DEFINE _ height 330/3

@ Interface view: uiview

@ End

. M file

//

// View. m

// 122chezhu01

//

// Created by Xumin on 7/8/13.

// Copyright (c) 2013 Xumin. All rights reserved.

//

# Import "view. H"

@ Implementation View

-(ID) initwithframe :( cgrect) Frame

{


Self = [Super
Initwithframe: frame];


If (Self ){

Self. backgroundcolor = [uicolor
Clearcolor];

}

Return
Self;

}

// Only override drawrect: If you perform custom drawing.

// An empty implementation adversely affects performance during animation.

-(Void) drawrect :( cgrect) rect

{

Cgcontextref context =
Uigraphicsgetcurrentcontext ();

Cgcontextsetstrokecolorwithcolor (context, [uicolor
Bluecolor]. cgcolor );

Cgcontextmovetopoint (context,
0, _ height );

Cgcontextaddlinetopoint (context,
320,
_ Height );

Cgcontextmovetopoint (context,
0, _ height * 2 );

Cgcontextaddlinetopoint (context,
320,
_ Height * 2 );

Cgcontextmovetopoint (context,
_ Weith,
0 );

Cgcontextaddlinetopoint (context,
_ Weith,
Self. Frame. Size. Height );

Cgcontextmovetopoint (context,
_ Weith * 2,
0 );

Cgcontextaddlinetopoint (context,
_ Weith * 2,
Self. Frame. Size. Height );

Cgcontextstrokepath (context );

Cgcontextclosepath (context );

}

@ End

Draw a straight line of the 9th Grid

Related Article

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.