In Xcode 6.1. 'UIImage?' does not have a member named 'size' Error

前端 未结 4 967
既然无缘
既然无缘 2020-12-04 03:36

I\'m getting an image\'s Size and used the below code. It was working perfectly fine with Xcode 6.0.1. After updating to Xcode 6.1, I\

4条回答
  •  無奈伤痛
    2020-12-04 03:45

    In addition to @Antonio's answer you can use nil coalescing operator(??) to get a default size in case image initializer is failed. Here is how:

    let size = image?.size ?? CGSizeZero
    

提交回复
热议问题