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