Untitled

 avatar
unknown
plain_text
5 months ago
1.3 kB
2
Indexable
{
        let cell = collectionView.cellForItem(at: indexPath) as? NewAgendaCollectionTypesCell
        let labelText = (arrOfTypes[indexPath.item]as? NSDictionary)?["type_name"] as? String ?? ""
        cell?.lblTypeName.text = labelText
        cell?.lblTypeName.font = UIFont(name: "DMSans24pt-Bold", size: 15.0)
        let size = (Utility.initUtility()?.width(of: String(format: "%@", labelText), with:FontBoldWithSize(15.0)) ?? 0)
        var labelFont_icon = (arrOfTypes[indexPath.item]as? NSDictionary)?["font_icon"] as? String ?? ""
        var width: CGFloat = 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