Naqeeb
Naqeeb

Reputation: 1421

Argument labels do not match any available overloads swift

i have a function which draw text on image but issue is when i call this function it gives a error "Argument labels '(_:, _:)' do not match any available overloads" i am new to swift and dont know how to fix

func write_text_on_image(drawtext text:NSString , inimage img : UIImage , atpoint point : CGPoint) -> UIImage {

        let textcolor = UIColor.white
        let font = UIFont(name: "Helvetica", size: 16)

        let scale = UIScreen.main.scale
        UIGraphicsBeginImageContextWithOptions(img.size, false, scale)

        let font_attributes = [

            kCTFontAttributeName : font,
            kCTForegroundColorAttributeName : textcolor
        ]

      img.draw(in: CGRect(origin: CGPoint.zero, size: img.size))

        let rect = CGRect(origin: point, size: img.size)

        text.draw(in: rect, withAttributes: font_attributes as [NSAttributedString.Key : Any])

        let newimg = UIGraphicsGetImageFromCurrentImageContext()

        UIGraphicsEndPDFContext()

        return newimg!

    }

i am calling this func as

write_text_on_image(drawtext: "THis is some text", inimage: UIImage(named: "test.png")!, atpoint: CGPoint(20,20))[!

check out screen of function [calling of function ]1

Upvotes: 1

Views: 828

Answers (2)

Goal Tech
Goal Tech

Reputation: 167

CGPoint(x,y) pass perameter as CGPoint(x : value,y ; value)

Upvotes: 1

Ron
Ron

Reputation: 748

As @vadian said, code completion would help you. This is what I got from duplicating a fragment in Playground:

func write_text_on_image(drawtext text:NSString , inimage img : UIImage , atpoint point : CGPoint) -> UIImage { return UIImage() }

write_text_on_image(drawtext: "NSString", inimage: UIImage(), atpoint: CGPoint(x: 0, y: 0))

Doesn't do anything, but compiles.

Upvotes: 1

Related Questions