Skip to content

Conversation

@Satish24sp
Copy link

@Satish24sp Satish24sp commented Sep 13, 2023

Added support for multiple lines title text with swipe menu segment style so that we can overcome the issue of text truncation.

Support has been added in the below classes:

1. SwipeMenuView.swift at L38 to L41
Added new public parameter in a function i.e. public struct ItemView {....}
After:

 /// ItemView title number of lines . Defaults to `1`.
      public var numberOfLines: Int = 1

2. TabView.swift at L218 to L224.
Modified the existing function i.e. fileprivate func setupTabItemViews(dataSource: TabViewDataSource) {....}
Before:

if let title = dataSource.tabView(self, titleForItemAt: index) {
   tabItemView.titleLabel.text = title
   tabItemView.titleLabel.font = options.itemView.font
   tabItemView.textColor = options.itemView.textColor
   tabItemView.selectedTextColor = options.itemView.selectedTextColor
}

After:


if let title = dataSource.tabView(self, titleForItemAt: index) {
   let itemView = options.itemView
                
   tabItemView.titleLabel.text = title
   tabItemView.titleLabel.numberOfLines = itemView.numberOfLines      // Change for multiple lines
   tabItemView.titleLabel.font = itemView.font
   tabItemView.textColor = itemView.textColor
   tabItemView.selectedTextColor = itemView.selectedTextColor
}

Final Result:

Before Changes:
Simulator Screenshot - iPhone 14 Pro - 2023-09-13 at 20 52 11

After Changes:
Simulator Screenshot - iPhone 14 Pro - 2023-09-13 at 20 52 21

Regards.

Added support for multiple lines title text with swipe menu segment style so that we can overcome the issue of text truncation.

Support has been added in the below classes:
1. SwipeMenuView.swift at L38 to L41, and
2. TabView.swift at L218 to L224.

Regards.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant