大佬教程收集整理的这篇文章主要介绍了如何将Int32值转换为CGFloat?,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
let width = CMVideoFormatDescriptionGetDimensions(device.activeFormat.formatDescription as CMVideoFormatDescriptionRef!)。width – return Int32
let height = CMVideoFormatDescriptionGetDimensions(device.activeFormat.formatDescription as CMVideoFormatDescriptionRef!)。height – return Int32
@H_404_15@myLayer?.frame = CGRectMake(0,0,width,height)错误是’Int32’不能转换为CGFloat,如何将Int32转换为CGFloat?
在你的情况下,你可以做:
@H_450_27@let width = CGFloat(CMVideoFormatDescriptionGetDimensions(device.activeFormat.formatDescription as CMVideoFormatDescriptionRef!).width) let height = CGFloat(CMVideoFormatDescriptionGetDimensions(device.activeFormat.formatDescription as CMVideoFormatDescriptionRef!).height) myLayer?.frame = CGRectMake(0,width,height)要么:
@H_450_27@let width = CMVideoFormatDescriptionGetDimensions(device.activeFormat.formatDescription as CMVideoFormatDescriptionRef!).width let height = CMVideoFormatDescriptionGetDimensions(device.activeFormat.formatDescription as CMVideoFormatDescriptionRef!).height myLayer?.frame = CGRectMake(0,CGFloat(width),CGFloat(height))请注意,swift中的数字类型之间没有隐式或显式类型转换,所以您必须使用相同的模式,也可以将Int转换为Int32或UInt等。
以上是大佬教程为你收集整理的如何将Int32值转换为CGFloat?全部内容,希望文章能够帮你解决如何将Int32值转换为CGFloat?所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。