0

Going back through an old project I was going to add some features and ran into this error. Does anyone know how to eliminate this? It happened for the code below:

UInt32(CGGradientDrawingOptions.DrawsBeforeStartLocation) | UInt32(CGGradientDrawingOptions.DrawsAfterEndLocation))

Below is the full file:

import UIKit

class BackgroundView: UIView {

    override func drawRect(rect: CGRect) {

        // Background View

        //// Color Declarations
        var lightPurple: UIColor = UIColor(red: 0.377, green: 0.075, blue: 0.778, alpha: 1.000)
        var darkPurple: UIColor = UIColor(red: 0.060, green: 0.036, blue: 0.202, alpha: 1.000)

        let context = UIGraphicsGetCurrentContext()

        //// Gradient Declarations
        let purpleGradient = CGGradientCreateWithColors(CGColorSpaceCreateDeviceRGB(), [lightPurple.CGColor, darkPurple.CGColor], [0, 1])

        //// Background Drawing
        let backgroundPath = UIBezierPath(rect: CGRectMake(0, 0, self.frame.width, self.frame.height))
        CGContextSaveGState(context)
        backgroundPath.addClip()
        CGContextDrawLinearGradient(context, purpleGradient,
            CGPointMake(160, 0),
            CGPointMake(160, 568),
            UInt32(CGGradientDrawingOptions.DrawsBeforeStartLocation) | UInt32(CGGradientDrawingOptions.DrawsAfterEndLocation))
        CGContextRestoreGState(context)

    }
}
Asdrubal
  • 2,421
  • 4
  • 29
  • 37
Brandon
  • 507
  • 5
  • 21

2 Answers2

3

CGGradientDrawingOptions since Swift 2.0 implements OptionSetType. This means that | operator is no longer necessary and you can write it like this:

let options: CGGradientDrawingOptions = [.DrawsBeforeStartLocation, .DrawsAfterEndLocation]

To get more info you can go here

Community
  • 1
  • 1
Tomasz Bąk
  • 6,124
  • 3
  • 34
  • 48
-1

Try to group them in Array instead.

Lumialxk
  • 6,239
  • 6
  • 24
  • 47
R.P. Carson
  • 439
  • 5
  • 20