简体   繁体   中英

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

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)
    }

枚举类型名称UIView.ContentMode是Swift 4.2中的新增功能,是Xcode 10中引入的。在此之前(例如,您所说的Xcode 9)是UIViewContentMode

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM