2019-12-19 17:32:49 +00:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
|
|
|
*
|
|
|
|
|
* This source code is licensed under the MIT license found in the
|
|
|
|
|
* LICENSE file in the root directory of this source tree.
|
2016-11-16 16:01:27 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
import UIKit
|
|
|
|
|
|
|
|
|
|
final class DemoCell: UICollectionViewCell {
|
2017-05-16 14:30:08 +00:00
|
|
|
|
2016-11-16 16:01:27 +00:00
|
|
|
lazy var label: UILabel = {
|
|
|
|
|
let view = UILabel()
|
|
|
|
|
view.textColor = .black
|
|
|
|
|
view.font = .boldSystemFont(ofSize: 35)
|
|
|
|
|
self.contentView.addSubview(view)
|
|
|
|
|
return view
|
|
|
|
|
}()
|
2017-05-16 14:30:08 +00:00
|
|
|
|
2016-11-16 16:01:27 +00:00
|
|
|
override func layoutSubviews() {
|
|
|
|
|
super.layoutSubviews()
|
|
|
|
|
contentView.backgroundColor = UIColor.white.withAlphaComponent(0.3)
|
|
|
|
|
label.frame = contentView.bounds.insetBy(dx: 32, dy: 16)
|
|
|
|
|
}
|
2017-05-16 14:30:08 +00:00
|
|
|
|
2016-11-16 16:01:27 +00:00
|
|
|
override func didUpdateFocus(in context: UIFocusUpdateContext, with coordinator: UIFocusAnimationCoordinator) {
|
|
|
|
|
let newBackgroundOpacity: CGFloat = isFocused ? 0.6 : 0.3
|
|
|
|
|
let newFontSize: CGFloat = isFocused ? 50 : 35
|
|
|
|
|
|
|
|
|
|
contentView.backgroundColor = UIColor.white.withAlphaComponent(newBackgroundOpacity)
|
|
|
|
|
label.font = .boldSystemFont(ofSize: newFontSize)
|
|
|
|
|
}
|
2017-05-16 14:30:08 +00:00
|
|
|
|
2016-11-16 16:01:27 +00:00
|
|
|
}
|