2014-03-03 4 views
0

이 drawque 메서드에 대한 활동 표시기 (HUD 중간에 있음)를 추가 할 수있는 방법을 알고 싶습니다. (해당 활동과 함께 허드를 만들려고합니다)drawRect에 UIActivityIndicator를 추가하는 방법

- (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]; 
} 

감사!

+0

drawRect : 사용자 정의보기 내에서 확실합니다. 따라서 스토리 보드에서이보기로 활동 표시기를 드래그하십시오. –

답변

1

그렇지 않습니다. 활동 표시기는보기 유형이므로 HUD의 하위보기로 추가하면 자체적으로 그려집니다.