mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-08-08 08:31:13 +00:00
Fix segmented control sizeToFit layout
This commit is contained in:
parent
d88f4ae9dc
commit
0979e02ab7
@ -291,8 +291,6 @@ public final class SegmentedControlNode: ASDisplayNode, UIGestureRecognizerDeleg
|
|||||||
public func updateLayout(_ layout: SegmentedControlLayout, transition: ContainedViewLayoutTransition) -> CGSize {
|
public func updateLayout(_ layout: SegmentedControlLayout, transition: ContainedViewLayoutTransition) -> CGSize {
|
||||||
self.validLayout = layout
|
self.validLayout = layout
|
||||||
|
|
||||||
let calculatedWidth: CGFloat = 0.0
|
|
||||||
|
|
||||||
let width: CGFloat
|
let width: CGFloat
|
||||||
let height: CGFloat
|
let height: CGFloat
|
||||||
switch layout {
|
switch layout {
|
||||||
@ -300,6 +298,14 @@ public final class SegmentedControlNode: ASDisplayNode, UIGestureRecognizerDeleg
|
|||||||
width = targetWidth
|
width = targetWidth
|
||||||
height = 32.0
|
height = 32.0
|
||||||
case let .sizeToFit(maximumWidth, minimumWidth, targetHeight):
|
case let .sizeToFit(maximumWidth, minimumWidth, targetHeight):
|
||||||
|
var calculatedWidth: CGFloat = 0.0
|
||||||
|
var maxWidth: CGFloat = 0.0
|
||||||
|
for item in self.itemNodes {
|
||||||
|
let size = item.calculateSizeThatFits(CGSize(width: maximumWidth, height: targetHeight))
|
||||||
|
maxWidth = max(maxWidth, size.width)
|
||||||
|
}
|
||||||
|
calculatedWidth = ceil(maxWidth * CGFloat(self.itemNodes.count))
|
||||||
|
|
||||||
width = max(minimumWidth, min(maximumWidth, calculatedWidth))
|
width = max(minimumWidth, min(maximumWidth, calculatedWidth))
|
||||||
height = targetHeight
|
height = targetHeight
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user