0

この drawrect メソッドにアクティビティ インジケーター (HUD の途中) を追加する方法を知りたいです (アクティビティを含む hud を作成しようとしています)。

- (void)drawRect:(CGRect)rect {

// Sets the rectangle to be 96 X 96.
const CGFloat boxWidth = 120.0f;
const CGFloat boxHeight = 120.0f;

// This method is used to calculate the position of the rectangle.
CGRect boxRect = CGRectMake( roundf(self.bounds.size.width - boxWidth) / 2.0f, roundf(self.bounds.size.height - boxHeight) / 2.0f, boxWidth,boxHeight);

// This draws the rectangle with rounded corners.
UIBezierPath *roundedRect = [UIBezierPath bezierPathWithRoundedRect:boxRect cornerRadius:10.0f];

[[UIColor colorWithWhite:0.0f alpha:0.75] setFill];

[roundedRect fill];

[[UIColor whiteColor] set]; // Sets the color of the font to white.

UIFont *font = [UIFont boldSystemFontOfSize:16.0f]; // Sets the size of the font to 16.

CGSize textSize = [self.text sizeWithFont:font];

// Calculates where to draw the text.
CGPoint textPoint = CGPointMake( self.center.x - roundf(textSize.width / 2.0f), self.center.y - roundf(textSize.height / 2.0f) + boxHeight / 4.0f);


// Draws the text on the rectangle.
[self.text drawAtPoint:textPoint withFont:font];
}

ありがとう!

4

1 に答える 1

1

あなたはそうしない。アクティビティ インジケーターは一種のビューなので、HUD のサブビューとして追加すると、それ自体が描画されます。

于 2014-03-03T21:48:46.877 に答える