Binary operator '|' cannot be applied to two UIViewAutoresizing operands

后端 未结 6 1792
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-22 23:02

Getting this error in Swift 2.0.

Binary operator \'|\' cannot be applied to two UIViewAutoresizing operands

Here is the code:

相关标签:
6条回答
  • 2020-12-22 23:44

    The OptionSetType got an updated syntax for Swift 2.x and another update for Swift 3.x

    Swift 3.x

    view.autoresizingMask = [.flexibleWidth, .flexibleHeight]
    

    Swift 2.x

    view.autoresizingMask = [.FlexibleWidth, .FlexibleHeight]
    
    0 讨论(0)
  • 2020-12-22 23:46

    This are the differences between Swift 1.2 and 2:

    // swift 1.2
    view.autoresizingMask = .FlexibleWidth | .FlexibleTopMargin
    
    // swift 2
    view.autoresizingMask = [.FlexibleWidth, .FlexibleTopMargin]
    
    0 讨论(0)
  • 2020-12-22 23:52

    Try with xcode7-b6:

    view.autoresizingMask = UIViewAutoresizing.FlexibleWidth.union(UIViewAutoresizing.FlexibleHeight)
    
    0 讨论(0)
  • 2020-12-22 23:56

    use this code swift 2 with Xcode 7.2

    self.view.autoresizingMask = [.FlexibleRightMargin, .FlexibleLeftMargin, .FlexibleBottomMargin, .FlexibleTopMargin]
    
    0 讨论(0)
  • 2020-12-23 00:01

    actual for swift 3.0.2:

    view.autoresizingMask = [.layerWidthSizable, .layerHeightSizable]
    
    0 讨论(0)
  • 2020-12-23 00:05

    For Swift 3 Xcode 8 b1:

    view.autoresizingMask = [.flexibleWidth, .flexibleHeight]
    
    0 讨论(0)
提交回复
热议问题