Skip to content

Commit

Permalink
Merge pull request #15 from abema/fix-minimum-item-width
Browse files Browse the repository at this point in the history
タブアイテムの最小幅を設定できるようにした
  • Loading branch information
YugoMatsuda committed Mar 13, 2024
2 parents f018533 + 085b8dd commit 25c7994
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
5 changes: 5 additions & 0 deletions Sources/SwipeMenuView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,13 @@ public struct SwipeMenuViewOptions {

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

/// ItemViewminimum width.
/// needsAdjustItemViewWidth がtrueの際に設定した値以下のWidthにならないように調整する
public var minimumItemWidth: CGFloat = 0

/// ItemView side padding. Defaults to `5.0`.
public var padding: CGFloat = 5.0

Expand Down
4 changes: 3 additions & 1 deletion Sources/TabView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,9 @@ open class TabView: UIScrollView {
case .flexible:
if options.needsAdjustItemViewWidth {
var adjustCellSize = tabItemView.frame.size
adjustCellSize.width = tabItemView.titleLabel.sizeThatFits(containerView.frame.size).width + options.itemView.padding * 2
let adjustWidth = tabItemView.titleLabel.sizeThatFits(containerView.frame.size).width + options.itemView.padding * 2
let adjustCellSizeWidth = max(adjustWidth, options.itemView.minimumItemWidth)
adjustCellSize.width = adjustCellSizeWidth
tabItemView.frame.size = adjustCellSize

containerView.addArrangedSubview(tabItemView)
Expand Down

0 comments on commit 25c7994

Please sign in to comment.