Reputation: 900
I'm attempting to blend two images together for a photo app and it calls for using drawInRect. This seemed like a simple concept in Obj-C, but I'm having issues wrapping my head around it in Swift for some reason.
This is one of MANY attempts by me to get this working:
secondImage.drawInRect(((origin.x * xScale), (origin.y * yScale), size.width * xScale, size.height * yScale, blendMode: kCGBlendModeNormal, alpha: 1.0)
I've tried other ways, but I keep getting told that I can't use CGFloats or CGPoints (which seems odd to me) and I'm not sure how else to express this. The Apple Documentation seems unclear to me: https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIImage_Class/#//apple_ref/occ/instm/UIImage/drawInRect:
But maybe it's just me. Can anyone tell me what parameters I need to give drawInRect?
Upvotes: 3
Views: 3797
Reputation: 10682
In swift 4 drawInRect
was renamed to:
your_image.draw(in: CGRect, blendMode: CGBlendMode, alpha: CGFloat)
Upvotes: 1
Reputation: 11597
drawInRect:
takes in a CGRect
as a parameter (as the name implies)
use
secondImage.drawInRect(CGRect(x: <#CGFloat#>, y: <#CGFloat#>, width: <#CGFloat#>, height: <#CGFloat#>), blendMode: kCGBlendModeNormal, alpha: 1.0)
in the parameter
Upvotes: 1