Here my code. I am passing two values into CGRectMake(..)
and getting and error.
let width = CMVideoFormatDescriptionGetDimensions(device.activeFormat.formatDescription as CMVideoFormatDescriptionRef!).width
// return Int32 value
let height = CMVideoFormatDescriptionGetDimensions(device.activeFormat.formatDescription as CMVideoFormatDescriptionRef!).height
// return Int32 value
myLayer?.frame = CGRectMake(0, 0, width, height)
// returns error: '`Int32`' not convertible to `CGFloat`
How can I convert Int32
to CGFloat
to not return an error?
Int
toCGFloat
conversion might be time consuming. Consider using different methods if API is available. For example, you can createCGSize
fromInt
, and then dolet dividedSize =size.applying(.init(scaleX: 0.5, y: 0.5))
, instead of converting Int's to CGFloat for dividing. – Geomorphic