'ContentMode' is not a member type of 'UIView'

╄→гoц情女王★ 提交于 2020-01-14 03:34:29

问题


I have the following piece of code which works well for a legacy IOS app, but now no longer works in xcode 9:

The error I'm getting is:

'ContentMode' is not a member type of 'UIView'

Here is the code:

import Foundation

struct ImageViewLayout {
    static func frameForImageWithSize(_ image: CGSize, previousFrame: CGRect, inContainerWithSize container: CGSize, usingContentMode contentMode: UIView.ContentMode) -> CGRect {
        let size = sizeForImage(image, previousSize: previousFrame.size, container: container, contentMode: contentMode)
        let position = positionForImage(size, previousPosition: previousFrame.origin, container: container, contentMode: contentMode)

        return CGRect(origin: position, size: size)
    }

回答1:


The enum type name UIView.ContentMode is new in Swift 4.2, introduced in Xcode 10. Before that (e.g. Xcode 9, as you say) it was UIViewContentMode.



来源:https://stackoverflow.com/questions/52416192/contentmode-is-not-a-member-type-of-uiview

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!