I basically have this SF Symbol: chevron.left
, and I want to get the width and height of this symbol, which I did like this:
public func getSize() -> CGSize {
let size = self.imgView!.size
return size
}
This is how I generate the SF Symbol:
UIImage(
systemName: name,
withConfiguration: UIImage.SymbolConfiguration(textStyle: .title1))?
.withTintColor(UIColor.TextColor!)
.withRenderingMode(.alwaysOriginal)
I expect the size of the UIImage, which is inside a UIButton to be equal to UIFont.preferredFont(forTextStyle: .title1).pointSize
, but, instead the height of the SF Symbol is bigger than what I expect it to be.
for .title1
the height should be 28 points, instead it's 33.3333 points, this is a strange behaviour.
--
*I'm using width and height anchors to constraint the width and the height of the button to the size I receive from getSize()
*contentMode
is equal to .scaleAspectFit
*clipToBounds
is true
, I've tried with false
as well, same result.
According to @DonMag in the comments of my post, it's actually an issue with SF Symbols. They've linked an answer(from them in the past), this is the link to that:
Custom UIImageView is not circle inside custom UITableViewCell
All props to them.