mirror of
https://github.com/wahyd4/Yep.git
synced 2026-08-15 15:55:59 +10:00
better logic of footerCellHeight
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user