Reference: if Apple is not so cool, we don't need to customize it. Unfortunately, UIActivityIndicator has only one initialization method, initWithActivityIndicatorStyle. I. It cannot be changed at Will-sometimes we need an invincible firewheel that is larger than UIActivityIndicatorViewStyleWhiteLarge; I. It is not friendly-we need to display some friendly prompts below the firewheel. To this end, we use a UIActivityIndicator control and Quartz plotting to customize our own invincible firewheel at any cost. The main idea of achieving your own invincible firewheel is as follows: 1. first, create a MyProgressView class to inherit the UIView, because we plan to create a new UIView, Add Indicator and text on it, draw the background, and then put the View in the current interface. 2. then, the MyprogressView is operated. The initWithFrame is rewritten, and the position and size of Indicator and Lable are fixed based on the transmitted coordinates and sizes, and add it to our defined external framework viewHud. 3. override drawRect to determine whether the custom view is visible. When visible, draw the rounded rectangle. Draw the route based on CGRect and fill the color of the route based on CGContextFillPath, this function is executed after the custom view is displayed, so we can shift the view in it, shift the CGRect through the CGRectOffset function, or call alignToCenter to center it. show, hide, SetMessage is mainly used to perform further operations on the view we define. 5. alignToCenter is mainly used to shift the current custom view. Please refer to the source code: MyProgressView. h file [objc] /// MyProgressView. h // FourthIOSProject /// Created by Mac on 14-4-16. // Copyright (c) 2014 Mac. all rights reserved. // # import <Foundation/Foundation. h> # import <UIKit/UIKit. h> @ interface MyProgressView: UIView {UIActivityIndicatorView * indicator; UILabel * label; BOOL visible, blocked; UIVi Ew * maskView; CGRect rectHud, rectSuper, rectOrigin; // shell area, parent view area UIView * viewHud; // shell} @ property (assign) BOOL visible;-(id) initWithFrame :( CGRect) frame superView :( UIView *) superView;-(void) show :( BOOL) block; // block: whether to block parent view-(void) hide;-(void) setMessage :( NSString *) newMsg;-(void) alignToCenter; @ end MyProgressView. m file [objc] view plaincopyprint? View the CODE piece derived from my CODE piece on CODE /// MyProgressView. m // FourthIOSProject /// Created by Mac on 14-4-16. // Copyright (c) 2014 Mac. all rights reserved. // # import "MyProgressView. h "@ implementation MyProgressView @ synthesize visible;-(id) initWithFrame :( CGRect) frame superView :( UIView *) superView {rectOrigin = frame; rectSuper = [superView bounds]; // keep the square ratio rectHud = CGRectMake (frame. origin. x, frame. origin. y, fram E. size. width, frame. size. width); self = [super initWithFrame: rectHud]; if (self) {self. backgroundColor = [UIColor clearColor]; self. opaque = NO; viewHud = [[UIView alloc] initWithFrame: rectHud]; [self addSubview: viewHud]; indicator = [[UIActivityIndicatorView alloc] callback: callback]; double gridUnit = round (rectHud. size. width/12); float ind_width = 6 * g RidUnit; indicator. frame = CGRectMake (3 * gridUnit, 2 * gridUnit, ind_width, ind_width); [viewHud addSubview: indicator]; CGRect rectLabel = CGRectMake (1 * gridUnit, 9 * gridUnit, 10 * gridUnit, 2 * gridUnit); label = [[UILabel alloc] initWithFrame: rectLabel]; label. backgroundColor = [UIColor clearColor]; label. font = [UIFont fontWithName: @ "Arial" size: 14]; label. textAlignment = UITextAlignmentCenter; label. textColor = [UIC Olor whiteColor]; label. text = @ "Please wait... "; label. adjustsFontSizeToFitWidth = YES; [viewHud addSubview: label]; visible = NO; [self setHidden: YES]; [superView addSubview: self];} return self ;} # pragma mark Drawing-(void) drawRect :( CGRect) rect {if (visible) {CGContextRef context = UIGraphicsGetCurrentContext (); CGRect boxRect = rectHud; // draw the rounded rectangle float radius = 10.0f; // The path starts CGContextBeginPath (context ); // Fill color: grayscale 0.0, transparency: 0.1 CGContextSetGrayFillColor (context, 0.0f, 0.25); // move the paint brush to the arc at the upper left corner CGContextMoveToPoint (context, CGRectGetMinX (boxRect) + radius, CGRectGetMinY (boxRect); // start to draw the arc in the upper right corner: center x coordinate, center y coordinate, start angle, end angle, and clockwise CGContextAddArc (context, CGRectGetMaxX (boxRect) -radius, CGRectGetMinY (boxRect) + radius, radius, 33 * (float) M_PI/2, 0, 0); // start to draw the lower right arc CGContextAddArc (context, CGRectGetMaxX (boxRect)- Radius, CGRectGetMaxY (boxRect)-radius, radius, 0, (float) M_PI/2, 0); // start to draw the lower left arc CGContextAddArc (context, CGRectGetMinX (boxRect) + radius, CGRectGetMaxY (boxRect)-radius, radius, (float) M_PI/2, (float) M_PI, 0); // start to draw the upper left corner of the arc CGContextAddArc (context, CGRectGetMinX (boxRect) + radius, CGRectGetMinY (boxRect) + radius, radius, (float) M_PI, 33 * (float) M_PI/2, 0); // NSLog (@ "MinX is: % f ", CGRectGet MinX (boxRect); // NSLog (@ "MaxX is: % f", CGRectGetMaxX (boxRect); // NSLog (@ "MinY is: % f ", CGRectGetMinY (boxRect); // NSLog (@ "MaxY is: % f", CGRectGetMaxY (boxRect); // CGContextClosePath (context ); // close the path CGContextFillPath (context); // fill the path. This function automatically closes the path // translate the screen in this direction // [self setFrame: CGRectOffset (self. frame, 100,160)]; // This line of code is newly added, indicating that after the painting is finished, the presentation screen is placed in the middle of the screen [self alignToCenter];} # pragma mark Action-(void) sho W :( BOOL) block {if (block & blocked = NO) {CGPoint offset = self. frame. origin; // change the view size to the parent View Size self. frame = rectSuper; viewHud. frame = CGRectOffset (viewHud. frame, offset. x, offset. y); if (maskView = nil) {maskView = [[UIView alloc] initWithFrame: rectSuper];} else {maskView. frame = rectSuper;} maskView. backgroundColor = [UIColor clearColor]; [self addSubview: maskView]; [self bringSubviewToFront: maskView]; bloc Ked = YES;} [indicator startAnimating]; [self setHidden: NO]; [self setNeedsLayout]; visible = YES;} # pragma mark hides this stuff-(void) hide {visible = NO; [indicator stopAnimating]; [self setHidden: YES] ;}# change the text in The pragma mark-(void) setMessage :( NSString *) newMsg {label. text = newMsg;} # pragma mark center this item-(void) alignToCenter {CGPoint centerSuper = {rectSuper. size. width/2, rectSuper. size. height/2}; CGPoint cente RSelf = {self. frame. origin. x + self. frame. size. width/2, self. frame. origin. y + self. frame. size. height/2}; CGPoint offset = {centerSuper. x-centerSelf.x, centerSuper. y-centerSelf.y}; CGRect newRect = CGRectOffset (self. frame, offset. x, offset. y); [self setFrame: newRect]; rectHud = newRect; // NSLog (@ "newRect: % f, % f", newRect. origin. x, newRect. origin. y) ;}@ end so how can I reference the above Code to produce results? The reference code in ViewController. m is as follows: [objc] view plaincopyprint? View the CODE piece on the CODE and derive it to my CODE piece-(void) viewDidLoad {[super viewDidLoad]; // Do any additional setup after loading the view. // Add an Activity Indicator View to the page. // This is not required. It is too ugly. Now it is too big. // UIActivityIndicatorView * indicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle: UIActivityIndicatorViewStyleGray]; // [indicator setCenter: CGPointMake (100,100)]; // [self. view addSubview: indicator]; // [indicat Or startAnimating]; MyProgressView * indicator = [[MyProgressView alloc] initWithFrame: CGRectMake (0, 0,120,120) superView: self. view]; [indicator setMessage: @ "Please wait while accepting ECG data... "]; if (indicator. visible = NO) {[indicator show: NO];} else {[indicator hide];} I wanted Indicator to appear when loading the page, use [objc] [indicator hide]; just hide it.