Skip to content

Commit

Permalink
frame re-adjustments for description label and its sizing
Browse files Browse the repository at this point in the history
  • Loading branch information
nimati committed Dec 10, 2016
1 parent 20b0f7b commit 83dd3f7
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 20 deletions.
2 changes: 1 addition & 1 deletion Example/FCAlertView/ExampleViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger
headerView.backgroundColor = [UIColor colorWithWhite:239.0f/255.0f alpha:1.0];

UILabel *headerLabel = [[UILabel alloc] initWithFrame:CGRectMake(20, 20, headerView.frame.size.width - 60, 20)];
headerLabel.text = @"NEW FEATURES • V1.2.0";
headerLabel.text = @"NEW FEATURES • V1.2.0+";

NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:@"NEW FEATURES • V1.2.0"];
[attributedString addAttribute:NSKernAttributeName
Expand Down
14 changes: 7 additions & 7 deletions Example/Pods/FCAlertView/FCAlertView/Classes/FCAlertView.m

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion FCAlertView.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

Pod::Spec.new do |s|
s.name = 'FCAlertView'
s.version = '1.2.7'
s.version = '1.2.8'
s.summary = 'FCAlertView is a Flat Customizable AlertView'

# This description is used to generate tags and improve search results.
Expand Down
20 changes: 9 additions & 11 deletions FCAlertView/Classes/FCAlertView.m
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,7 @@ - (id)init

defaultSpacing = [self configureAVWidth];
defaultHeight = [self configureAVHeight];

[self checkCustomizationValid];


}

return self;
Expand Down Expand Up @@ -354,12 +352,14 @@ - (void)drawRect:(CGRect)rect {
else
descriptionLabel.font = [UIFont systemFontOfSize:16.0f weight:UIFontWeightRegular];

descriptionLabel.numberOfLines = 6;
descriptionLabel.textColor = self.subTitleColor;
descriptionLabel.text = self.subTitle;
descriptionLabel.textAlignment = NSTextAlignmentCenter;
descriptionLabel.adjustsFontSizeToFitWidth = NO;

descriptionLabel.numberOfLines = 0;
descriptionLabel.lineBreakMode = NSLineBreakByTruncatingTail;

// Re-adjusting Frames based on height of text - Requirement is to not have over 6 lines of text

CGSize constraint = CGSizeMake(descriptionLabel.frame.size.width, CGFLOAT_MAX);
Expand All @@ -370,18 +370,16 @@ - (void)drawRect:(CGRect)rect {
options:NSStringDrawingUsesLineFragmentOrigin
attributes:@{NSFontAttributeName:descriptionLabel.font}
context:context].size;

sizeOfText = CGSizeMake(ceil(boundingBox.width), MIN(ceil(boundingBox.height), 108));

CGFloat heightDiff = descriptionLabel.frame.size.height - sizeOfText.height;

CGFloat heightDiff = descriptionLabel.frame.size.height - boundingBox.height;

descriptionLabel.frame = CGRectMake(descriptionLabel.frame.origin.x,
descriptionLabel.frame.origin.y + 7.5,
descriptionLabel.frame.size.width,
sizeOfText.height);
boundingBox.height);

alertViewFrame = CGRectMake(alertViewFrame.origin.x,
alertViewFrame.origin.y,
alertViewFrame.origin.y + ((heightDiff + 15)/2),
alertViewFrame.size.width,
alertViewFrame.size.height - heightDiff + 15);

Expand Down Expand Up @@ -1650,4 +1648,4 @@ - (void) setActiveRating:(NSInteger)rating {

}

@end
@end

0 comments on commit 83dd3f7

Please sign in to comment.