Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for multiple lines title text #123

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

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.

None yet

1 participant