Divide a ring 12 equal (any equal)
1 //2 //VIEWCONTROLLER.M3 //Twelve4 //5 //Created by Yuency on 17/4/2.6 //Copyright 2017 yuency. All rights reserved.7 //8 9 #import "ViewController.h"Ten One #defineDegrees_to_radians (angle) ((angle)/180.0 * M_PI) A - - @interfaceViewcontroller () the - @end - - @implementationViewcontroller + -- (void) Viewdidload { + [Super Viewdidload]; A at - //12 equal, each ring angle is 30°, in this 30° the part and the hidden part of the display - - #warningModify such fractions -Nsinteger Equalcount = A; - #warningProportion of colored areas inCGFloat visiableproportion =. 9f; - to + //calculate the angle of the equal -CGFloat Equalangle = the/Equalcount; the //calculate the angle of the visible area *CGFloat Visiableangle = Equalangle *visiableproportion; $ //The connection becomes a curved linePanax NotoginsengUibezierpath *circlepath =[Uibezierpath Bezierpath]; - for(inti =0; I < A; i + +) { theCGFloat startangle = (i *equalangle); +CGFloat Endangle = (Visiableangle + i *equalangle); AUibezierpath *path = [Uibezierpath bezierpathwitharccenter:cgpointmake (0,0) Radius: $/2. F Startangle:degrees_to_radians (StartAngle) Endangle:degrees_to_radians (Endangle) clockwise:yes]; the [Circlepath Appendpath:path]; + } - //Create Shapes $Cashapelayer *circlelayer =[Cashapelayer layer]; $Circlelayer.path =Circlepath.cgpath; -Circlelayer.strokecolor =[Uicolor Magentacolor]. Cgcolor; -Circlelayer.fillcolor =[Uicolor Clearcolor]. Cgcolor; theCirclelayer.linewidth =10.0f; -Circlelayer.strokestart =0.0f;WuyiCirclelayer.strokeend =1.0f; theCirclelayer.position =Self.view.center; - [Self.view.layer Addsublayer:circlelayer]; Wu - About $ //Reference Line -UIView *VVV = [[UIView alloc] Initwithframe:cgrectmake (0,0, -,1)]; -Vvv.backgroundcolor =[Uicolor Redcolor]; -Vvv.center =Self.view.center; A [Self.view ADDSUBVIEW:VVV]; +UIView *mmm = [[UIView alloc] Initwithframe:cgrectmake (0,0,1, the)]; theMmm.backgroundcolor =[Uicolor Redcolor]; -Mmm.center =Self.view.center; $ [Self.view addsubview:mmm]; the } the the the @end
ios-a Ring 12 equal (any equal)