1 #import "BNRHypnosisView.h"2 3 @implementationBnrhypnosisview4-(Instancetype) initWithFrame: (CGRect) Frame5 {6Self =[Super Initwithframe:frame];7 if(self)8 {9Self.backgroundcolor =[Uicolor Clearcolor];Ten } One returnSelf ; A } -- (void) DrawRect: (cgrect) Rect - { theCGRect bounds =self.bounds; - - //According to Bounds Computing center point - Cgpoint Center; +center.x = bounds.origin.x + bounds.size.width/2.0; -CENTER.Y = bounds.origin.y + bounds.size.height/2.0; + A //calculates the radius of a circle based on the lesser values of the wide chart and high schools at //Float radius = (MIN (bounds.size.width, Bounds.size.height))/2.0; - - //make the outermost circle a circumscribed circle of the view - floatMaxradius = Hypot (bounds.size.width, bounds.size.height)/2.0; - - //This object is used to draw lines or curves, which make up various shapes. inUibezierpath *path =[[Uibezierpath alloc]init]; - //center point, radius value is radius, defines a path from 0 to M_pi *2.0 radians (full circle) to //[Path Addarcwithcenter:center + //Radius:radius - //startangle:0.0 the //ENDANGLE:M_PI * 2.0 * //Clockwise:yes]; $ Panax Notoginseng for(floatCurrentradius = Maxradius; Currentradius >0; Currentradius-= -) - { the //The original concentric circle produces a handwriting that appears when it is drawn and needs to be removed +[Path moveToPoint: (Cgpoint) {center.x +currentradius,center.y}]; A [Path Addarcwithcenter:center the Radius:currentradius +StartAngle:0.0 -endangle:m_pi*2.0 $ Clockwise:yes]; $ } - - //set the line width to 10 points thePath.linewidth =Ten; - Wuyi //set paint color to light gray the [[Uicolor Redcolor] setstroke]; - Wu [path stroke]; -}
Simple Concentric circle effect