I am trying to apply my custom attributes to "attributedDescription" and "attributedCredit" for the Photo object and apparently, I can only see the color attribute working but not for the font style and the paragraphStyle. Do I miss anything in the setup?
var photos:[PhotoProtocol] = []
for (index, eachLink) in self.photosLink.enumerated() {
let p = Photo()
p.url = URL(string: eachLink)
if let cell = self.collectionView.cellForItem(at: indexPath) as? HHCVCell, index == indexPath.row {
let image = cell.imageview.image
p.image = image
}
let descriptionText = "Description goes here. \(index)"
let creditText = "Image Credit \(index)"
let desciptionAttributes = [NSAttributedStringKey.foregroundColor: HBConstants.Style.galleryCaptionColor, NSAttributedStringKey.font: HBConstants.Style.galleryCaptionFont]
let description = NSAttributedString(string: descriptionText, attributes: desciptionAttributes)
let paragraphStyle = NSMutableParagraphStyle()
paragraphStyle.alignment = .right
let creditAttributes = [NSAttributedStringKey.foregroundColor: HBConstants.Style.galleryCreditColor, NSAttributedStringKey.font: HBConstants.Style.galleryCreditFont, NSAttributedStringKey.paragraphStyle: paragraphStyle]
let credit = NSAttributedString(string: creditText, attributes: creditAttributes)
p.attributedDescription = description
p.attributedCredit = credit
photos.append(p)
}
let dataSource = PhotosDataSource(photos: photos, initialPhotoIndex: indexPath.row, prefetchBehavior: .aggressive)
Hi Alex,
I am trying to apply my custom attributes to "attributedDescription" and "attributedCredit" for the Photo object and apparently, I can only see the color attribute working but not for the font style and the paragraphStyle. Do I miss anything in the setup?