The implementation of the rendering process, though low, is easier to understand.
Take a look at the layers, you can see that the implementation method is relatively simple
@property (Nonatomic,strong) UIView *circleview; Loop Display View
@property (Nonatomic,strong) UIView *dianliangview; The first layer of water wave view
@property (Nonatomic,strong) UIView *dianliangview2; The second layer of water wave view
/** Round Cashapelayer * *
@property (Nonatomic,strong) Cashapelayer *ovalshapelayer;
@property (Nonatomic,strong) UISlider *slider;
@property (Nonatomic,strong) Nstimer *watertimer;
@property (Nonatomic,strong) Nstimer *watertimer2;
@property (Nonatomic,strong) Uilabel *dianlianglbel;
-(void) Viewdidload {
[Superviewdidload];
Self.view.backgroundColor = [uicolorcolorwithred:0.25green:0.39blue:0.68alpha:1.00];
Waterheight = (WIDTH-140);
Electric power slide Dashed round view=============
Self.circleview = [[Uiviewalloc]initwithframe:cgrectmake (Width/2-(WIDTH-100)/2,100,width-100,width-100)];
[Self.viewaddSubview:self.circleView];
Self.circleView.layer.cornerRadius = (WIDTH-100)/2;
Self.circleView.layer.masksToBounds = YES;
Self.circleView.backgroundColor = [Uicolorclearcolor];
Self.circleView.transform = Cgaffinetransformmakerotation (-m_pi_2);
First layer of light white dashed circle
Cashapelayer *ovallayer = [Cashapelayerlayer];
Ovallayer.strokecolor = [uicolorcolorwithred:0.64green:0.71blue:0.87alpha:1.00]. Cgcolor;
Ovallayer.fillcolor = [Uicolorclearcolor]. Cgcolor;
Ovallayer.linewidth = 10;
Ovallayer.linedashpattern =@[@2,@6];
Ovallayer.path = [Uibezierpathbezierpathwithovalinrect:cgrectmake (5,5,2 * (WIDTH-100)/2-10,2 * (WIDTH-100)/2-10)]. Cgpath;
[Self.circleView.layeraddSublayer:ovalLayer];
The second layer of yellow dashed round the amount of electricity
Self.ovalshapelayer = [Cashapelayerlayer];
Self.ovalShapeLayer.strokeColor = [Uicoloryellowcolor]. Cgcolor;
Self.ovalShapeLayer.fillColor = [Uicolorclearcolor]. Cgcolor;
Self.ovalShapeLayer.lineWidth = 10;
Self.ovalShapeLayer.lineDashPattern = @[@2,@6];
CGFloat Refreshradius = (WIDTH-100)/2;
Self.ovalShapeLayer.path = [Uibezierpathbezierpathwithovalinrect:cgrectmake (5,5,2 * refreshradius-10,2 * REFRESHRADIUS-10)]. Cgpath;
self.ovalShapeLayer.strokeEnd = 0;
[Self.circleView.layeraddSublayer:self.ovalShapeLayer];
Small circle with white solid line
Cashapelayer *ocirclelayer = [Cashapelayerlayer];
Ocirclelayer.strokecolor = [uicolorcolorwithred:0.64green:0.71blue:0.87alpha:1.00]. Cgcolor;
Ocirclelayer.fillcolor = [Uicolorclearcolor]. Cgcolor;
Ocirclelayer.linewidth = 1;
Ocirclelayer.path = [Uibezierpathbezierpathwithovalinrect:cgrectmake (15,15,2 * (WIDTH-100)/2-30,2 * (WIDTH-100)/2-30 )]. Cgpath;
[Self.circleView.layeraddSublayer:ocircleLayer];
Sliding Slider ==========================
Self.slider = [[Uislideralloc]initwithframe:cgrectmake (100,height-100,width-200,20)];
[Self.viewaddSubview:self.slider];
[Self.slideraddTarget:selfaction: @selector (slideraction:) forcontrolevents:uicontroleventvaluechanged];
///
UIView *backview = [[Uiviewalloc]initwithframe:cgrectmake (Width/2-(WIDTH-100)/2 + +20,width-140,width-140)];
[Self.viewaddSubview:backView];
BackView.layer.cornerRadius = (WIDTH-140)/2;
BackView.layer.masksToBounds =yes;
Backview.backgroundcolor = [uicolorcolorwithred:0.26green:0.34blue:0.50alpha:1.00];
First layer of water ripple view ===========================
Self.dianliangview = [[Uiviewalloc]initwithframe:cgrectmake (Width/2-(WIDTH-100)/2 + +20,width-140,width-140) ];
[Self.viewaddSubview:self.dianliangView];
Self.dianliangView.layer.cornerRadius = (WIDTH-140)/2;
Self.dianliangView.layer.masksToBounds = YES;
Self.dianliangView.backgroundColor = [uicolorcolorwithred:0.34green:0.40blue:0.71alpha:0.80];
Second layer of water ripple view =======================
Self.dianliangview2 = [[Uiviewalloc]initwithframe:cgrectmake width/2-(WIDTH-100)/2 + +20,width-140,width-140 )];
[SELF.VIEWADDSUBVIEW:SELF.DIANLIANGVIEW2];
Self.dianliangView2.layer.cornerRadius = (WIDTH-140)/2;
Self.dianliangView2.layer.masksToBounds = YES;
Self.dianliangView2.backgroundColor = [uicolorcolorwithred:0.32green:0.52blue:0.82alpha:0.60];
///
Self.dianlianglbel = [[Uilabelalloc]initwithframe:cgrectmake width/2-(WIDTH-100)/2 + +20 + (WIDTH-140)/2-30, WIDTH-140,60)];
[Self.viewaddSubview:self.dianliangLbel];
Self.dianliangLbel.font = [Uifont systemfontofsize:50];
Self.dianliangLbel.textAlignment = Nstextalignmentcenter;
Self.dianliangLbel.textColor = [Uicolorwhitecolor];
Self.watertimer = [Nstimerscheduledtimerwithtimeinterval:0.08target:selfselector: @selector (waterAction) UserInfo: Nilrepeats:yes];
Self.watertimer2 = [Nstimerscheduledtimerwithtimeinterval:0.10target:selfselector: @selector (WaterAction2) UserInfo:nilrepeats:YES];
}
-(void) wateraction{
Cgmutablepathref Wavepath =cgpathcreatemutable ();
Cgpathmovetopoint (wavepath,nil,0,-watermaxheight*0.5);
Float y = 0;
_horizontal +=0.15;
for (float x =0 <=self.dianliangView.frame.size.width; x + +) {
Crest *sin (Number of x * m_pi/self.dianliangview.frame.size.width * peaks + moving distance)
y = 7*sin (x *m_pi/self.dianliangview.frame.size.width * 2-_horizontal)/move right;
Cgpathaddlinetopoint (Wavepath,nil, X, y+waterheight);
}
Cgpathaddlinetopoint (Wavepath,nil,self.dianliangview.frame.size.width, watermaxheight*0.5);
Cgpathaddlinetopoint (Wavepath,nil,self.dianliangview.frame.size.width,watermaxheight);
Cgpathaddlinetopoint (wavepath,nil,0, watermaxheight);
[Self.dianliangViewsetShape:wavePath];
}
-(void) wateraction2{
Cgmutablepathref wavePath2 =cgpathcreatemutable ();
Cgpathmovetopoint (wavepath2,nil,0,-watermaxheight*0.5);
float y2 = 0;
_horizontal2 +=0.1;
for (float x2 =0 x2 <=self.dianliangView2.frame.size.width; x2++) {
Crest * SIN (number of x * m_pi/self.dianliangview2.frame.size.width * peaks + moving distance)
y2 = -5*cos (x2 *m_pi/self.dianliangview2.frame.size.width * 2 + _horizontal2)///move left;
Cgpathaddlinetopoint (Wavepath2,nil, x2, y2+waterheight);
}
Cgpathaddlinetopoint (Wavepath2,nil,self.dianliangview2.frame.size.width, watermaxheight*0.5);
Cgpathaddlinetopoint (Wavepath2,nil,self.dianliangview2.frame.size.width,watermaxheight);
Cgpathaddlinetopoint (wavepath2,nil,0, watermaxheight);
[Self.dianliangView2setShape:wavePath2]; This code needs to use the Uiview+shape.h file
}
-(void) Slideraction: (UISlider *) slider{
Self.ovalShapeLayer.strokeEnd = Slider.value;
if (slider.value >=0 | | | Slider.value <=1) {
Waterheight = (1-slider.value) * (WIDTH-140);
Self.dianliangLbel.text = [nsstringstringwithformat:@ "%.0f%@", slider.value*100,@ "%"];
}else{
NSLog (@ "Progress value is Error");
}
}
Link: Https://pan.baidu.com/s/1o7TLuqA Password: DSFI