1

Hi I tried to add an UIImageView in my textField called typeDeProbleme. All works just fine, there's no error shown, except when I try to click on the typeDeProbleme, XCode gives me this in the Target Output:

[Unknown process name] CGContextSetFillColorWithColor: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable.

let imageView = UIImageView()
let image = UIImage(named: "arrow")
imageView.image = image
imageView.frame = CGRect(x: 0, y: 0, width: 25, height: 15)
imageView.contentMode = .scaleAspectFit
typeDeProbleme.rightViewMode = UITextFieldViewMode.always
typeDeProbleme.rightView = imageView
typeDeProbleme.addSubview(imageView)

I already tried to understand from this CGContextSetFillColorWithColor: invalid context 0x0 but i can't because it's in Objective-C. Therefore, I just want to know, did I missed something here?

zaki
  • 41
  • 5

1 Answers1

0

Try this i think this will help you...

    let rightView = UIView(frame: CGRect(x: 0, y: 0, width: 25, height: 15))
    let imageView = UIImageView(frame: CGRect(x: 0, y: 0, width: 25, height: 15))
    imageView.image = UIImage(named: "arrow")
    rightView.addSubview(imageView)

    typeDeProbleme.rightView = rightView
    typeDeProbleme.rightViewMode = .always
Zee
  • 327
  • 1
  • 8
  • Unfortunately not... thanks for the help though.. if you know what is the problem, could you please explain it to me? – zaki Oct 06 '17 at 14:09