Search code examples
swiftcgrect

Xcode Swift error following ugrade to swift 3.0 - CGRectMake


I am attempting to get an image to display/align correctly to the left of some text. Prior to upgrading to Swift 3.0, I obtain the task using the following:

textLabel?.frame = CGRectMake(56, textLabel!.frame.origin.y, textLabel!.frame.width, textLabel!.frame.height)

detailTextLabel?.frame = CGRectMake(56, detailTextLabel!.frame.origin.y, detailTextLabel!.frame.width, detailTextLabel!.frame.height)

I got the error:

CGRectMake is unavailable in Swift

so I modified the line(s) to reflect the following:

textLabel?.frame = CGRect(origin: CGPoint(x:0,y:0), size: CGSize(width: 150, height:50))

but the image now displays on top of the text. Could I get some assistance as to what would be the proper syntax to resolve the issue?


Solution

  • CGRect(x:56, y:detailTextLabel!.frame.origin.y, width: detailTextLabel!.frame.width, height: detailTextLabel!.frame.height)