Skip to content

Commit 25c7994

Browse files
authored
Merge pull request #15 from abema/fix-minimum-item-width
タブアイテムの最小幅を設定できるようにした
2 parents f018533 + 085b8dd commit 25c7994

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

Sources/SwipeMenuView.swift

+5
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,13 @@ public struct SwipeMenuViewOptions {
1919

2020
public struct ItemView {
2121
/// ItemView width. Defaults to `100.0`.
22+
/// needsAdjustItemViewWidth がfalseの際に適用される
2223
public var width: CGFloat = 100.0
2324

25+
/// ItemViewminimum width.
26+
/// needsAdjustItemViewWidth がtrueの際に設定した値以下のWidthにならないように調整する
27+
public var minimumItemWidth: CGFloat = 0
28+
2429
/// ItemView side padding. Defaults to `5.0`.
2530
public var padding: CGFloat = 5.0
2631

Sources/TabView.swift

+3-1
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,9 @@ open class TabView: UIScrollView {
235235
case .flexible:
236236
if options.needsAdjustItemViewWidth {
237237
var adjustCellSize = tabItemView.frame.size
238-
adjustCellSize.width = tabItemView.titleLabel.sizeThatFits(containerView.frame.size).width + options.itemView.padding * 2
238+
let adjustWidth = tabItemView.titleLabel.sizeThatFits(containerView.frame.size).width + options.itemView.padding * 2
239+
let adjustCellSizeWidth = max(adjustWidth, options.itemView.minimumItemWidth)
240+
adjustCellSize.width = adjustCellSizeWidth
239241
tabItemView.frame.size = adjustCellSize
240242

241243
containerView.addArrangedSubview(tabItemView)

0 commit comments

Comments
 (0)