Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 209 Vote(s) - 3.49 Average
  • 1
  • 2
  • 3
  • 4
  • 5
'CGPointMake' is unavailable in swift

#1
I have a Gradient class which I am trying to convert to Swift 3 but I get the following error

> 'CGPointMake' is unavailable in swift

for

func configureGradientView() {

let color1 = topColor ?? self.tintColor as UIColor
let color2 = bottomColor ?? UIColor.black as UIColor
let colors: Array <AnyObject> = [ color1.cgColor, color2.cgColor ]
let layer = self.layer as! CAGradientLayer

layer.colors = colors
layer.startPoint = CGPointMake(startX, startY)
layer.endPoint = CGPointMake(endX, endY)
}

Can anyone help me out with what I can use instead of `CGPointMake`

Here's the full class;

@IBDesignable public class XGradientView: UIView {

@IBInspectable public var topColor: UIColor? {
didSet {
configureGradientView()
}
}
@IBInspectable public var bottomColor: UIColor? {
didSet {
configureGradientView()
}
}
@IBInspectable var startX: CGFloat = 0.0 {
didSet{
configureGradientView()
}
}
@IBInspectable var startY: CGFloat = 1.0 {
didSet{
configureGradientView()
}
}
@IBInspectable var endX: CGFloat = 0.0 {
didSet{
configureGradientView()
}
}
@IBInspectable var endY: CGFloat = 0.0 {
didSet{
configureGradientView()
}
}

public class func layeredClass() -> AnyClass {
return CAGradientLayer.self
}

public required init(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)!
configureGradientView()
}

override init(frame: CGRect) {
super.init(frame: frame)
configureGradientView()
}

public override func tintColorDidChange() {
super.tintColorDidChange()
configureGradientView()
}

func configureGradientView() {

let color1 = topColor ?? self.tintColor as UIColor
let color2 = bottomColor ?? UIColor.black as UIColor
let colors: Array <AnyObject> = [ color1.cgColor, color2.cgColor ]
let layer = self.layer as! CAGradientLayer

layer.colors = colors
layer.startPoint = CGPointMake(startX, startY)
layer.endPoint = CGPointMake(endX, endY)
}
}

Reply

#2
swift 3 emphasizes in use of named Parameters.

`CGPoint` Can be created like this.

let point = CGPoint(x: 0,y :0) // CGFloat, Double, Int

Reply

#3
In swift you can create a `CGPoint` in swifty way `CGPoint(x: xPos, y:yPos)`.
So change your `CGPointMake(startX, startY)` to `CGPoint(x: startX, y: startY)`
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through