Zhang Hang

Refactor

@@ -124,16 +124,11 @@ @@ -124,16 +124,11 @@
124 CGFloat rad = centerPercentage * 2 * M_PI; 124 CGFloat rad = centerPercentage * 2 * M_PI;
125 125
126 UILabel *descriptionLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 100, 80)]; 126 UILabel *descriptionLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 100, 80)];
127 - NSString *titleText = currentDataItem.textDescription; 127 + NSString *titleText = [NSString stringWithFormat:@"%.0f%%",[self ratioForItemAtIndex:index] * 100];
128 - if(!titleText){ 128 + if(currentDataItem.textDescription){
129 - titleText = [NSString stringWithFormat:@"%.0f%%",[self ratioForItemAtIndex:index] * 100]; 129 + titleText = [titleText stringByAppendingFormat:@"\n%@",currentDataItem.textDescription];
130 - descriptionLabel.text = titleText ;  
131 - }  
132 - else {  
133 - NSString* str = [NSString stringWithFormat:@"%.0f%%\n",[self ratioForItemAtIndex:index] * 100];  
134 - str = [str stringByAppendingString:titleText];  
135 - descriptionLabel.text = str ;  
136 } 130 }
  131 + descriptionLabel.text = titleText;
137 132
138 CGPoint center = CGPointMake(_outerCircleRadius + distance * sin(rad), 133 CGPoint center = CGPointMake(_outerCircleRadius + distance * sin(rad),
139 _outerCircleRadius - distance * cos(rad)); 134 _outerCircleRadius - distance * cos(rad));