Hello, I have been having trouble with configuring the systemImage size. I took a number of approaches but couldn't manage to set a size to the systemImage within the collectionView cell. Because of this, the text which is supposed to be below the image, clashes with the image due to its large size within the cell. The last approach I took with the code I'm sharing, I get an empty cell. Otherwise, I can't find a way to change the systemImage size. Could you please advise me regarding the configuration of systemImage ?
Many Thanks.
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
if collectionView == collectionViewEffects {
let cellEffects = collectionView.dequeueReusableCell(withReuseIdentifier: "EffectsCell", for: indexPath) as! CustomEffectsCell
collectionView.backgroundColor = .systemGray6
if indexPath.row == 0 {
cellEffects.effectsLabel = "A"
let config = UIImage.SymbolConfiguration(pointSize: 0, weight: .ultraLight)
let cellImage = UIImage(systemName: "slider.horizontal.3", withConfiguration: config)
let width = ((cellImage?.size.width)!)/4
let height = ((cellImage?.size.height)!)/4
guard let context = UIGraphicsGetCurrentContext() else {
print("could not get graphics context")
return cellEffects
}
context.setStrokeColor(UIColor.yellow.cgColor)
context.setLineWidth(2)
context.stroke(cellImage?.cgImage as! CGRect)
cellImage?.draw(in: CGRect(x: 0, y: 0, width: width, height: height))
cellEffects.effectsImage = cellImage
self.view.addSubview(cellEffects)
}