Untitled

 avatar
unknown
plain_text
5 months ago
1.6 kB
2
Indexable
{
        let cell = collectionView.cellForItem(at: indexPath) as? NewAgendaCollectionTypesCell
//        let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "NewAgendaCollectionTypesCell", for: indexPath) as? NewAgendaCollectionTypesCell
       
        let labelData: [String: Any] = arrOfTypes[indexPath.item]
        let labelText: String = labelData["name"] as? String ?? ""
        cell?.lblTypeName.text = labelText
        cell?.lblTypeName.font = FontBoldWithSize(15.0)
//        let width: CGFloat = 20 + (Utility.initUtility()?.width(of: String(format: "%@", labelText), with: UIFont(name: "Lato-Regular", size: 14)) ?? 0) + 25
        var labelFont_icon = (arrOfTypes[indexPath.item] as? NSDictionary)?["font_icon"] as? String ?? ""
        var width: CGFloat = 0.0
        let size = (Utility.initUtility()?.width(of: String(format: "%@", labelText), with:FontBoldWithSize(14.0)) ?? 0)
        if labelFont_icon != ""{
            var rmWhiteSpace = [String]()
            if labelFont_icon.contains(" "){
                rmWhiteSpace = labelFont_icon.components(separatedBy: " ")
                labelFont_icon = rmWhiteSpace[1]
            }

            let attrString = NSMutableAttributedString(
                        string: String.fontAwesomeIcon(code: labelFont_icon) ?? "",
                         attributes: [ .font: UIFont.fontAwesome(ofSize: 16, style: .solid)])
            if attrString.length > 0 {
                width = 20
            }
            width += size + 36
        }else {
            width = size + 26
        }
        return CGSize(width: width > 40 ? width : 40, height: 30)
    }
Editor is loading...
Leave a Comment