Kevin

Merge pull request #117 from MrWooJ/fixing-Issue#108

fixing issue #108
@@ -123,20 +123,27 @@ @@ -123,20 +123,27 @@
123 123
124 _currentTotal += currentDataItem.value; 124 _currentTotal += currentDataItem.value;
125 125
  126 + UILabel *descriptionLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 100, 80)];
126 NSString *titleText = currentDataItem.textDescription; 127 NSString *titleText = currentDataItem.textDescription;
127 if(!titleText){ 128 if(!titleText){
128 titleText = [NSString stringWithFormat:@"%.0f%%",currentDataItem.value/ _total * 100]; 129 titleText = [NSString stringWithFormat:@"%.0f%%",currentDataItem.value/ _total * 100];
  130 + descriptionLabel.text = titleText ;
  131 + }
  132 + else {
  133 + NSString* str = [NSString stringWithFormat:@"%.0f%%\n",currentDataItem.value/ _total * 100];
  134 + str = [str stringByAppendingString:titleText];
  135 + descriptionLabel.text = str ;
129 } 136 }
130 137
131 CGPoint center = CGPointMake(_outerCircleRadius + distance * sin(rad), 138 CGPoint center = CGPointMake(_outerCircleRadius + distance * sin(rad),
132 _outerCircleRadius - distance * cos(rad)); 139 _outerCircleRadius - distance * cos(rad));
133 140
134 - CGRect frame;  
135 - frame = CGRectMake(0, 0, 100, 80);  
136 -  
137 - UILabel *descriptionLabel = [[UILabel alloc] initWithFrame:frame];  
138 - descriptionLabel.text = titleText;  
139 descriptionLabel.font = _descriptionTextFont; 141 descriptionLabel.font = _descriptionTextFont;
  142 + CGSize labelSize = [descriptionLabel.text sizeWithAttributes:@{NSFontAttributeName:descriptionLabel.font}];
  143 + descriptionLabel.frame = CGRectMake(
  144 + descriptionLabel.frame.origin.x, descriptionLabel.frame.origin.y,
  145 + descriptionLabel.frame.size.width, labelSize.height);
  146 + descriptionLabel.numberOfLines = 0;
140 descriptionLabel.textColor = _descriptionTextColor; 147 descriptionLabel.textColor = _descriptionTextColor;
141 descriptionLabel.shadowColor = _descriptionTextShadowColor; 148 descriptionLabel.shadowColor = _descriptionTextShadowColor;
142 descriptionLabel.shadowOffset = _descriptionTextShadowOffset; 149 descriptionLabel.shadowOffset = _descriptionTextShadowOffset;
@@ -144,7 +151,6 @@ @@ -144,7 +151,6 @@
144 descriptionLabel.center = center; 151 descriptionLabel.center = center;
145 descriptionLabel.alpha = 0; 152 descriptionLabel.alpha = 0;
146 descriptionLabel.backgroundColor = [UIColor clearColor]; 153 descriptionLabel.backgroundColor = [UIColor clearColor];
147 -  
148 return descriptionLabel; 154 return descriptionLabel;
149 } 155 }
150 156