ios-a Ring 12 equal (any equal)

Source: Internet
Author: User

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)

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.