SwipeMenuViewController icon indicating copy to clipboard operation
SwipeMenuViewController copied to clipboard

Added support for multiple lines title text

Open Satish24sp opened this issue 1 year ago • 0 comments

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.

Satish24sp avatar Sep 13 '23 14:09 Satish24sp