Robbie Mills
Robbie Mills

Reputation: 2945

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

Upvotes: 2

Views: 2877

Answers (1)

matt
matt

Reputation: 535306

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.

Upvotes: 5

Related Questions