mirror of
https://github.com/Instagram/IGListKit
synced 2026-05-06 15:08:50 +00:00
Differential Revision: D19141253 fbshipit-source-id: 9ed4c278a91bb48a1f6d33cafa9ce8f21861573d
34 lines
1 KiB
Swift
34 lines
1 KiB
Swift
/*
|
|
* 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.
|
|
*/
|
|
|
|
import UIKit
|
|
|
|
final class DemoCell: UICollectionViewCell {
|
|
|
|
lazy var label: UILabel = {
|
|
let view = UILabel()
|
|
view.textColor = .black
|
|
view.font = .boldSystemFont(ofSize: 35)
|
|
self.contentView.addSubview(view)
|
|
return view
|
|
}()
|
|
|
|
override func layoutSubviews() {
|
|
super.layoutSubviews()
|
|
contentView.backgroundColor = UIColor.white.withAlphaComponent(0.3)
|
|
label.frame = contentView.bounds.insetBy(dx: 32, dy: 16)
|
|
}
|
|
|
|
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)
|
|
}
|
|
|
|
}
|