Changed "done" to "save" in the English translation and made tiny code tweaks

This commit is contained in:
Deniz Duezgoeren
2019-07-22 14:10:08 +02:00
parent 0298383465
commit e04d458b8b
10 changed files with 167 additions and 102 deletions
+1 -76
View File
@@ -7,83 +7,8 @@
//
import UIKit
import MagazineLayout
class MenuViewCell: MagazineLayoutCollectionViewCell {
class MenuViewCell: GenericViewCell {
@IBOutlet weak var content: UILabel!
private var widthConstraint: NSLayoutConstraint!
public override init(frame: CGRect) {
super.init(frame: frame)
contentView.translatesAutoresizingMaskIntoConstraints = false
let bottomConstraint = bottomAnchor.constraint(equalTo: contentView.bottomAnchor)
bottomConstraint.priority = .required - 1
NSLayoutConstraint.activate(
[
leadingAnchor.constraint(equalTo: contentView.leadingAnchor),
trailingAnchor.constraint(equalTo: contentView.trailingAnchor),
topAnchor.constraint(equalTo: contentView.topAnchor),
bottomConstraint
]
)
widthConstraint = widthAnchor.constraint(equalToConstant: bounds.width)
widthConstraint.priority = .required - 1
widthConstraint.isActive = true
}
required public init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
}
override open func awakeFromNib() {
super.awakeFromNib()
contentView.translatesAutoresizingMaskIntoConstraints = false
let bottomConstraint = bottomAnchor.constraint(equalTo: contentView.bottomAnchor)
bottomConstraint.priority = .required - 1
NSLayoutConstraint.activate(
[
leadingAnchor.constraint(equalTo: contentView.leadingAnchor),
trailingAnchor.constraint(equalTo: contentView.trailingAnchor),
topAnchor.constraint(equalTo: contentView.topAnchor),
bottomConstraint
]
)
widthConstraint = widthAnchor.constraint(equalToConstant: bounds.width)
widthConstraint.priority = .required - 1
widthConstraint.isActive = true
}
override open func preferredLayoutAttributesFitting(
_ layoutAttributes: UICollectionViewLayoutAttributes)
-> UICollectionViewLayoutAttributes
{
guard let attributes = layoutAttributes as? MagazineLayoutCollectionViewLayoutAttributes else {
assertionFailure("`layoutAttributes` must be an instance of `MagazineLayoutCollectionViewLayoutAttributes`")
return super.preferredLayoutAttributesFitting(layoutAttributes)
}
let size: CGSize
if attributes.shouldVerticallySelfSize {
widthConstraint.constant = layoutAttributes.size.width
size = super.preferredLayoutAttributesFitting(layoutAttributes).size
} else {
// No self-sizing is required; respect whatever size the layout determined.
size = layoutAttributes.size
}
layoutAttributes.size = size
return layoutAttributes
}
}