diff --git a/Yep/ViewControllers/Profile/ProfileViewController.swift b/Yep/ViewControllers/Profile/ProfileViewController.swift index b4605828..b2eeef4a 100644 --- a/Yep/ViewControllers/Profile/ProfileViewController.swift +++ b/Yep/ViewControllers/Profile/ProfileViewController.swift @@ -39,6 +39,13 @@ class ProfileViewController: UIViewController { @IBOutlet weak var profileCollectionView: UICollectionView! + lazy var footerCellHeight: CGFloat = { + let attributes = [NSFontAttributeName: profileIntroductionLabelFont] + let labelWidth = screenWidth - (profileIntroductionLabelLeadingSpaceToContainer + profileIntroductionLabelTrailingSpaceToContainer) + let rect = introductionText.boundingRectWithSize(CGSize(width: labelWidth, height: CGFloat(FLT_MAX)), options: .UsesLineFragmentOrigin | .UsesFontLeading, attributes:attributes, context:nil) + return ceil(rect.height) + }() + override func viewDidLoad() { super.viewDidLoad() @@ -200,12 +207,7 @@ extension ProfileViewController: UICollectionViewDataSource, UICollectionViewDel return CGSizeMake(cellWidth, cellHeight) case ProfileSection.Footer.rawValue: - - let attributes = [NSFontAttributeName: UIFont(name: "HelveticaNeue-Thin", size: 12)!] - let labelWidth = screenWidth - (profileIntroductionLabelLeadingSpaceToContainer + profileIntroductionLabelTrailingSpaceToContainer) - let rect = introductionText.boundingRectWithSize(CGSize(width: labelWidth, height: CGFloat(FLT_MAX)), options: .UsesLineFragmentOrigin | .UsesFontLeading, attributes:attributes, context:nil) - - return CGSizeMake(screenWidth, ceil(rect.height)) + return CGSizeMake(screenWidth, footerCellHeight) default: return CGSizeZero diff --git a/Yep/Views/Cells/ProfileFooter/ProfileFooterCell.swift b/Yep/Views/Cells/ProfileFooter/ProfileFooterCell.swift index 8fa87386..9e006133 100644 --- a/Yep/Views/Cells/ProfileFooter/ProfileFooterCell.swift +++ b/Yep/Views/Cells/ProfileFooter/ProfileFooterCell.swift @@ -10,13 +10,13 @@ import UIKit let profileIntroductionLabelLeadingSpaceToContainer: CGFloat = 20 let profileIntroductionLabelTrailingSpaceToContainer: CGFloat = 20 +let profileIntroductionLabelFont = UIFont(name: "HelveticaNeue-Thin", size: 12)! class ProfileFooterCell: UICollectionViewCell { @IBOutlet weak var instroductionLabelLeftConstraint: NSLayoutConstraint! @IBOutlet weak var instroductionLabelRightConstraint: NSLayoutConstraint! - @IBOutlet weak var introductionLabel: UILabel! override func awakeFromNib() { @@ -24,6 +24,8 @@ class ProfileFooterCell: UICollectionViewCell { instroductionLabelLeftConstraint.constant = profileIntroductionLabelLeadingSpaceToContainer instroductionLabelRightConstraint.constant = profileIntroductionLabelTrailingSpaceToContainer + + introductionLabel.font = profileIntroductionLabelFont } }