zekunyan / TTGTagCollectionView

Useful for showing text or custom view tags in a vertical or horizontal scrollable view and support Autolayout at the same time. It is highly customizable that most features of the text tag can be configured. 标签流显示控件,同时支持文字或自定义View
http://tutuge.me
MIT License
1.89k stars 260 forks source link

Requesting you to please provide me the solution for this as the second row text taking much spaces, I have set the number of lines 2, and the scroll direction would be Horizontal. #136

Closed Lokeshkumar0066 closed 1 year ago

Lokeshkumar0066 commented 1 year ago

IMG_9E1024D1F146-1

Lokeshkumar0066 commented 1 year ago

tagViewCollection.delegate = self tagViewCollection.scrollDirection = .horizontal tagViewCollection.alignment = .fillByExpandingWidth tagViewCollection.numberOfLines = 2 tagViewCollection.scrollView.showsHorizontalScrollIndicator = false tagViewCollection.horizontalSpacing = 20 tagViewCollection.verticalSpacing = 20 tagViewCollection.contentInset = UIEdgeInsets(top: 0, left: 12, bottom: 0, right: 0)

func generateTagData() { var tagData: [TTGTextTag] = [] self.tagViewCollection.removeAllTags() let data = homeVWmodel.textConcepts for dict in data { let imageText = dict.capitalized let replaceOcc = imageText.replacingOccurrences(of: "\n", with: " ") let width = replaceOcc.textWidth(font: UIFont(name: AppFonts.bold, size: 14)!) + 0 let content = TTGTextTagStringContent(text: replaceOcc, textFont: UIFont(name: AppFonts.bold, size: 14.0), textColor: UIColor(named:"CCFFDE")!) let style = TTGTextTagStyle() style.borderWidth = 2.0 style.exactHeight = 38 style.cornerRadius = 8.0 style.exactWidth = width style.borderColor = UIColor(named:"CCFFDE")! style.backgroundColor = .clear style.shadowColor = .clear let textTag = TTGTextTag(content: content, style: style) textTag.selectedStyle?.backgroundColor = .clear tagData.append(textTag) } if tagData.count > 0 { self.tagViewCollection.add(tagData) } }